Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: die through several evals

by BrowserUk (Pope)
on Apr 24, 2013 at 15:31 UTC ( #1030448=note: print w/ replies, xml ) Need Help??


in reply to Re^2: die through several evals
in thread die through several evals

... i'll stuck

Stuck where? Doing what?

I don't see anything getting "stuck"?:

sub mys{ print "??$_[0]??"; eval{ die 'bad stuff' if $_[0] eq 'die' }; };; print 'here'; eval{ mys( 'hello' ) }; print 'there'; eval{ mys( 'die' ) }; print 'over here';; here ??hello?? there ??die?? over here

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: die through several evals
Download Code
Re^4: die through several evals
by nyaapa (Novice) on Apr 24, 2013 at 17:33 UTC
    $SIG{ALRM} = sub { die "TIMEDOUT" }; my $sub = sub { warn "visible"; eval { # some big action in eval sleep(); }; warn "invisible"; }; # execute $sub with timeout alarm(1); $sub->();
    and get
    visible at -e line 1. invisible at -e line 1.

      That is exactly what is meant to happen.

      You wrap code in an eval in order to trap any error that might occur. If you then chose to not check for an error having occurred, then the code will continue as if no error had occurred.

      If you don't want the error to be ignored, you should either check for an error and rethrow if that is apppropriate; or don't use the eval in the first place.

      (And your 'visible'/'invisible' strings make no sense because: a) they are both visible; b) they should be!)

      I think that you'd better describe the overall goal you are trying to achieve, rather than looking to find a way to undo the very effect that the eval statement is designed to provide.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        i need function like with_timeout(&;$), it executes first argument with timeout. I can't use fork and storable/json, because of db handlers or something.
        also, i cant control passed sub for eval propagate.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-09-22 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls