in reply to Test for the last element in a foreach
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.
|
|---|