$SIG{ALRM} = sub { report(); exit }; alarm(86400 * 3); # your test code here ... # at the end, print report report(); sub report { # your reporting code }
At the end of your test script you invoke report(). If the script happens to run for three days, the alarm handler will invoke report() and terminate the script.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re^3: how to set alarm in perl
by shmem
in thread how to set alarm in perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |