So, I'm running into some trouble thinking of how to temporarily leave a for loop, only to return to it later. Ideally I'd like to return to the spot where I left off. I feel like there's some logic I'm missing somewhere.
To start, let's say I have:
-------
#some stuff foreach (@array) { $spot_in_array = $_; #some stuff if(CONDITION_MET){ #temporarily leave foreach } }
In the if statement, how would I leave the foreach loop without leaving permanently? I thought of using last but I know that wouldn't get me back into the loop. The reason why I added that $spot = $_; is because, I think I'm on the right track here, I may be able to use a for loop that starts at $spot and ends at the last index of @array. How I'd do this kind of stumps me. Would I start with a foreach loop at all? Or do I set $spot to the first item, and iterate through a for loop, in a nested while loop that returns every time if(!CONDITION_MET) happens, kind of like an on/off switch.
I've only picked up and been working with Perl for a few weeks, so there's a lot I still don't know. Any help would be greatly appreciated. Thanks.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |