Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Last undefines a for loop's itererator?

by BigLug (Chaplain)
on Nov 12, 2005 at 21:03 UTC ( [id://508017]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://508017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found