my $data=""; eval { local $SIG{ALRM} = sub { die "Alarm" }; alarm(2); my $ret; while(read(STDIN,$ret,1)) { $data.=$ret; } alarm(0); };