in reply to Re: how to set alarm in perl
in thread how to set alarm in perl

now i m confused
the above code will kill tests after there days. and it prints messages " 3 days over" and exits
i can also write a code to print final report inside the sub function
if test get over before 3 days then where should i place code to finally create a report.
i mean where to place code to check if test over before 3. should it come after above code or before above code.

Replies are listed 'Best First'.
Re^3: how to set alarm in perl
by shmem (Chancellor) on Sep 11, 2006 at 08:03 UTC
    $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}