use strict; use warnings; my $pwd = eval { local $SIG{ALRM} = sub { die "Alarm" }; alarm(5); my $x = 10; while($x--) { print STDERR "sleep $x"; sleep(1); } alarm(0); }; if ($@ and $@ =~ /Alarm/) { print "Problem! Zeit abgelaufen!\n"; } else { print "Alles klar!\n"; }