Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to set timer in perl

by hbm (Hermit)
on Jun 13, 2013 at 13:09 UTC ( #1038735=note: print w/ replies, xml ) Need Help??


in reply to How to set timer in perl

I've only needed alarm once, and this worked:

eval { local $SIG{__DIE__} = 'DEFAULT'; local $SIG{ALRM} = sub { die "timeout" }; alarm 2700; # do things alarm 0; }; if ($@) { if ($@ =~ "timeout" ) { ... } else { print "$@\n"; } alarm 0; }


Comment on Re: How to set timer in perl
Download Code
Re^2: How to set timer in perl
by perlfan (Curate) on Jun 13, 2013 at 16:05 UTC
    The documented example for alarm has a "\n" at the end of the die string, but also checks $@ with 'eq', not a regex like you are. Just thought I would point that out.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-10-25 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls