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";
Comment on Re^3: How to implement a timer in perl?