$SIG{ALRM} = \&timeout_code; alarm = $N; while () { $out .= ; } $SIG{ALRM} = "";