Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to set timer in perl

by hbm (Hermit)
on Jun 13, 2013 at 13:09 UTC ( [id://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 (Vicar) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1038735]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-03-19 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found