[Melbourne-pm] eval

Ryan Tan ryantanthechinaman at gmail.com
Thu Oct 27 21:08:38 PDT 2005


Hi...

I'm new to perl.

I have a following bit of code that runs some SOAP::Lite functions,
and with the nature of the web, it could return anything from 500 not
founds, to hanging etc.

I read a bit about using eval so it just reports the errors, but not die.

I'm trying to, in this code, say if the execution of takes more than
60 seconds, to kill it and start again.

I still need to notice the death and press ^C.

I am using W32... would this be easier under linux (and use fork etc).

Thanks

Ryan

CODE:

sub run
{
        for (my $a=0; $a<10000;$a++)
        {
                $SIG{ALRM} = \&timed_out;
                eval
                {
                        alarm(60);
                        &main;
                        alarm(0);
                }
        }
}
sub timed_out
{
        warn "\c something fishy going on\n";
        &run;
}


More information about the Melbourne-pm mailing list