in reply to Re^2: no chunk is too small
in thread Last undefines a for loop's itererator?
If it doesn't work under warnings and strict, there is probably a good reason for that. IMO, if you want to access the loop variable outside the loop, you should declare a separate variable and set it explicitly before you drop out of the loop.It does work fine under warnings and strict, if you don't declare your variable in the conditions on the for(..) loop. It has always seemed weird to me to write code like
Doesn't it just seem like a waste of variables? You're clearly using $i and $iold for the same purpose.my $iold; for my $i ( 1 .. $foo ) { if( bar($i) ) { $iold = $i; last; } }
As for why it isn't a subroutine, perhaps because I like this code all in one place. Shrug.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: no chunk is too small
by ewilhelm (Novice) on Nov 14, 2005 at 17:22 UTC | |
|
Re^4: no chunk is too small
by BrowserUk (Patriarch) on Nov 13, 2005 at 23:58 UTC | |
by Aristotle (Chancellor) on Nov 14, 2005 at 00:17 UTC | |
by BrowserUk (Patriarch) on Nov 14, 2005 at 00:51 UTC | |
by Aristotle (Chancellor) on Nov 14, 2005 at 01:09 UTC | |
by BrowserUk (Patriarch) on Nov 14, 2005 at 01:45 UTC | |
|