"...and modifying the iterator variable modifies the array that you are iterating through ..."
foreach my $a (@ar) ...
You are not using the "traditional" C style for loop. You are using the Perl style foreach loop. From perlsyn:
The "foreach" loop iterates over a normal list value and sets the scalar variable VAR to be each element of the list in turn.Big difference. You might be comparing apples to oranges here. Consider this code which actually changes the iterator variable instead of the element.
See the difference?my @ar = (1, 2, 3); for my $i (0 .. $#ar) { $i = $i + 1; } print join ", ", @ar; # prints 1, 2, 3
UPDATE:
I was attempting to point out that the OP mentioned "modifying the iterator variable" when they are actually modifying the "loop index variable" as perlsyn documents.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: A specific term for a Perlism
by jeffa
in thread A specific term for a Perlism
by JupiterCrash
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |