In the CB, I presented:
for my $i (0..$#array) { for ($array[$i]) { ... if ($i == $#array) { ... } ... } }
Using this method, no change will be required to the body of your loop. $_ is still aliased to the array element as it normally is in a foreach loop. Changes to it will be reflected in the array.
In reply to Re: Test for the last element in a foreach
by ikegami
in thread Test for the last element in a foreach
by tdevil76
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |