Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: fork, %SIG, END.

by eff_i_g (Curate)
on Aug 19, 2005 at 19:01 UTC ( [id://485271]=note: print w/replies, xml ) Need Help??


in reply to Re: fork, %SIG, END.
in thread fork, %SIG, END.

etm1777:

it is my understanding that the program does not exit within the END block, but after the END block has completed; the scope returns to a global (file) one, where $? is then returned, like so:
END { local $?; # preserve previous return code # do anything } # now, outside of the END block, # $? refers to the global and the # program officially terminates # using this value.

Replies are listed 'Best First'.
Re^3: fork, %SIG, END.
by etm117 (Pilgrim) on Aug 19, 2005 at 21:06 UTC
    I agree with that code block and think we are speaking towards the same thing. I use the local $? in my END block to preserve the exit code also.

    I think I brought it up as an heads up because that bit me in the butt when I first started using the END block, I wasn't preserving the $? and therefore code inside the END block was causing it to be modified and the script not exiting with the value I wanted.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found