in reply to Re: Unconventional exit from while loop
in thread Unconventional exit from while loop
not use last in this context anymore,
Ever since I replied above, this has been ticking over in the back of my mind: I wasn't quite sure quite why I so prefer the normal version.
Especially since I'm not adverse to using last in unusual ways.
And I think finally the penny has dropped. It's because it effectively renders that while loop condition test redundant, but doesn't stop being tested each time around the loop. So you are effectively testing two conditions every time, only one of which can ever be false.
Kind of like:
while( 1 ) { my( $w, $x, $y, $z ) = @{ $iter->next // last }; ... }
Except that the loop conditional isn't optimised away.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Unconventional exit from while loop
by LanX (Saint) on May 26, 2013 at 14:12 UTC | |
by BrowserUk (Patriarch) on May 26, 2013 at 14:19 UTC | |
|
Re^3: Unconventional exit from while loop
by hdb (Monsignor) on May 26, 2013 at 14:17 UTC | |
by BrowserUk (Patriarch) on May 26, 2013 at 14:21 UTC |