Sort of on the same topic (but maybe a bit in the opposite direction), does anybody know if there is a special variable that keeps count of which iteration in a for loop it's on?
Say I want to do something to every third element:
my $i = 0; foreach my $element (@array) { do_something($element) unless ($i++ % 3); }
Is there a special variable that tracks what $i is tracking in that example?
In reply to Re: Perlplexation - foreach shoulda Known
by Riales
in thread Perlplexation - foreach shoulda Known
by raybies
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |