in reply to Re: Last undefines a for loop's itererator?
in thread Last undefines a for loop's itererator?

Rather than using $i as your iterator, use the default $_. Then assign it's value to your 'custom iterator' inside the foreach.

foreach ( 1 .. $foo ) { $i = $_; last if bar($i); } print $i;

Replies are listed 'Best First'.
Re^3: Last undefines a for loop's itererator?
by kaif (Friar) on Nov 13, 2005 at 23:24 UTC
    Thank you very much. Of all the solutions, I like this the best.