"be consistent" | |
PerlMonks |
Re: Run 2 Subroutines after a dieby jarich (Curate) |
on Oct 03, 2002 at 07:17 UTC ( [id://202450]=note: print w/replies, xml ) | Need Help?? |
Try the following instead:
Then, if open fails you'll execute all the code in the block and then exit, which is what you're trying to do.
I alse get 1 at C:\Dev\MiscTests\sub.pl line 8die is a function that takes a string and exits the program printing that message out with the line number and script name. In this case die is getting the result of your do{} as its string and printing it: "1". The result of your do just happens to be the return value of your subroutine Two, which is 1. (print returns 1 if it printed, and if there is no explicit return, the value of the last line (of code) in a subroutine is the return value). If you try my suggestion from above, you won't get that any more. Hope it helps. jarich
Short answer to below I prefer unless because I find that sometimes I don't see the ! in if( !$foo ). Readability kinda depends on the reader. unless does take more character presses...
In Section
Seekers of Perl Wisdom
|
|