in reply to Is 'last' redundant in this code?
I'm wondering if 'last' is redundant if the call to the subroutine msg includes an 'exit'.It is indeed redundant as it will never be reached, and I wouldn't be surprised if it was optimised out (see. Aristotle's reply on why this can't be done). It could be seen as self-documenting code, but it could be somewhat misleading and msg() should be documented denoting the fact that it exit()s when called. In fact, it looks a little like die(), so you might just want to use that instead e.g
foreach (@array) { die "Yes, key found\n" if /key/; }
_________
broquaint
update: extraneous semi-colon encountered a Backspace
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is 'last' redundant?
by Improv (Pilgrim) on Apr 07, 2003 at 13:45 UTC | |
|
Re^2: Is 'last' redundant? (can't be optimized)
by Aristotle (Chancellor) on Apr 07, 2003 at 14:21 UTC |