Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Don't ask to ask, just ask
 
PerlMonks  

Re^7: foreach argument modification inside loop, followed by return from loop

by rjt (Chaplain)
on Jul 10, 2013 at 22:13 UTC ( #1043575=note: print w/ replies, xml ) Need Help??


in reply to Re^6: foreach argument modification inside loop, followed by return from loop
in thread foreach argument modification inside loop, followed by return from loop

As far as I can tell, you only ever look at the first element of the jobs array;

No, first job can return 'wait' and loop will jump next job after this line

return 'wait' unless --$maxcnt;

I see you're correct; as I mentioned, I only had time for a brief look so I could offer up some (illustrative) feedback on how you might approach your question of "Problem that I mentioned in my posting, followed by return from loop that "for" loop is in get_task(). i.e. there is another outer "for" loop.".

In any case, if you like, you can still use similar logic by shifting in a while loop, since you consume the element every time, and the shift of course doesn't care about changes from one loop iteration to the next.

Certainly, there are ways to make it bit better. But I actually think it's irrelevant to this topic :)

Ah, perhaps I've over-stayed my helpfulness. :-) Good luck! :-)


Comment on Re^7: foreach argument modification inside loop, followed by return from loop
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-04-17 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (458 votes), past polls