Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038735]
[Discipulus]: bravo! orange juice will help
[marto]: not on the Sun, it'd vaporise
[Corion]: marto: No, a Sun Balcony, it was an ill-fated attempt to revive the Sparc series after the Pizzabox :)
[marto]: ah Sun, I sold my Pizzabox in around 2005

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-03-21 11:15 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.