in reply to Re: How to implement a timer in perl?
in thread How to implement a timer in perl?

this example was just what I needed.

Thanks!!!

  • Comment on Re^2: How to implement a timer in perl?

Replies are listed 'Best First'.
Re^3: How to implement a timer in perl?
by Anonymous Monk on Feb 19, 2015 at 06:57 UTC
    print "What is your name Anonymous?\n"; eval { local $SIG{ALRM} = sub { die "Timeout" }; alarm 10; chomp($answer = <STDIN>); alarm 0; }; if ($@ and $@ =~ /Timeout/) { $answer = "Anonymous"; } print "Hello $answer!\n";