Can we see the non-working code that uses alarm? This is a textbook example of when to use alarm.
Here, the alarm is triggered, and then processing continues:
alarm 5;
$SIG{ALRM} = sub { print "alarm!\n" };
my $yawn = `sleep 10 ; echo "yawn"`;
print "yawn? $yawn\n";
__END__
alarm!
yawn? yawn
Sometimes when I execute programs from perl using system() they don't return and perl gets stuck. This fixes that.