Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Running code a certain amount of time

by ccn (Vicar)
on Oct 31, 2008 at 15:02 UTC ( [id://720714]=note: print w/replies, xml ) Need Help??


in reply to Running code a certain amount of time

use alarm function and catch SIG{ALRM} signal

sub some_sub { eval { local $SIG{ALRM} = sub {die "died in SIG ALRM";}; alarm(1); my $i=0; $i++ while 1; alarm(0); }; if ($@) { if ($@ =~ /died in SIG ALRM/) { print "caught\n"; } else { print $@; } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://720714]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found