Is there a better way to do this? Maybe through one of Perl's special variables? I thought about searching for the array index containing the current value (like, "what is the index of @array that contains $_"). Also, I'm not necessarily looking for a solution to give me a total end count of iterations, but more for telling me how many iterations I have gone through so I can say things like "print this line every 3rd time through the loop"$i = 0; foreach (@array) { # do stuff $i++; }
In reply to Of foreach loops and counting by Cirollo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |