my $retval = eval { local $SIG{ALRM} = sub { exit }; alarm 10; my $input = ''; while (<>) { $input .= $_; } alarm 0; return $input; }; print $retval;