Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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; }

Replies are listed 'Best First'.
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?
[MidLifeXis]: Project Admin, a while ago: "No, I would prefer you didn't close that ticket yet confirming $vendor's support process yet. Continue to periodically check back to see if it has changed."...
[MidLifeXis]: Project Admin, today, after many periodic updates from me: "Why hasn't this been closed yet? Is there anything I can do to get this closed?" <facepalm>
[MidLifeXis]: In addition to SOAP (last hour of cb), try water. ;-)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2017-01-19 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.