Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Stopping execution of an eval statement

by slloyd (Hermit)
on Jul 23, 2005 at 20:51 UTC ( [id://477516]=note: print w/replies, xml ) Need Help??


in reply to Re: Stopping execution of an eval statement
in thread Stopping execution of an eval statement

If i die in the handler, then the whole script would stop processing,not just the eval statement, right? I only want to kill executing the eval statement, not the entire script.
  • Comment on Re^2: Stopping execution of an eval statement

Replies are listed 'Best First'.
Re^3: Stopping execution of an eval statement
by polettix (Vicar) on Jul 23, 2005 at 21:12 UTC
    If i die in the handler, then the whole script would stop processing,not just the eval statement, right?
    Wrong.

    die inside an eval is a common idiom to have exception handling in Perl (see eval for examples, BTW). If you look at the example by dave_the_m, you'll see that the line after eval {long}; is printed - probably after the user has hit CTRL-C.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      Thank you for the clarafication. I modified the code slightly to show this a bit better. Run the following code. Then hit CTRL-C once to abort the eval statement, then wait and then hit CTRL-C to exit completely.
      use strict; $|=1; sub long { 1 while 1 } $SIG{INT} = sub { die "got int\n" }; print "SIG{INT}=$SIG{INT}\n"; eval {long}; print "got err: $@\n" if $@; print "Loop after first eval\n"; while(1){ select(undef,undef,undef,.25); } print "OK I am a done\n"; __END__

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-16 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found