eval { local $SIG{ALRM} = sub { die "Timed Out!\n" }; my $timeout = 30; # give 30 seconds to accept and process data my $previous_alarm = alarm($timeout); # get input # and do heavy and interesting and cool stuff :-) # ... # finished with this alarm($previous_alarm) }; # eval if ($@ =~ /timed out/i) { # check stuff, report error, etc }