sub go { my $self = shift @_; local $SIG{ALRM} = \&ti; eval { ... #### 5 seconds main input: no input running.... name name1 (2 seconds) sub input: no input running defaults..... name name2 (2 seconds) sub input: no input running defaults..... 5 seconds main input: no input running.... name name1 (2 seconds) sub input: no input running defaults..... name name2 (2 seconds) sub input: no input running defaults..... #### while() { eval { alarm(5); print "\n\n5 seconds main input: "; chomp(my $input = ); alarm(0); }; if ($@ =~ /BLAH/) { print "\n\nno input running....\n\n"; $engine->run(); } if ($@ =~ /TIMEOUT/) { print "\n\nOops, still using ti handler...\n\n"; } sub timed_out { die "BLAH"; } } #### 5 seconds main input: no input running.... name name1 (2 seconds) sub input: no input running defaults..... name name2 (2 seconds) sub input: no input running defaults..... Oops, still using ti handler... 5 seconds main input: Oops, still using ti handler... 5 seconds main input: Oops, still using ti handler...