Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?
[Corion]: hippo: Yeah, but at least two years ago, it still was close enough to 20% cut
[Corion]: But I have a very positive experience with a four day workweek and a three day weekend. I can't easily go back though to full money.
[Corion]: That is easy without having to pay for a house, a wife or children though. If I had any of these, or any two of these, the decision wouldn't be that easy.
[ambrus]: wait. I understand no wife and children, but how do you not have to pay for a house?
[hippo]: I had a low-paid job about 20 years ago and seriously considered going down to a 3-day week. Would have worked 60% of the time for about 80% of the cash.
[Corion]: ambrus: Well, I pay rent, but don't own a house with variable/ unforeseeable costs
[hippo]: The thesholds/benefits balance at the time was nuts.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2017-09-21 15:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (249 votes). Check out past polls.

    Notices?