The problem is not the type of for loop, the problem is starting at the beginning of the array when changing the number of elements in the array.
If you are going to remove elements of an array in a for loop you have to start at the end of the array.
So this might work UNTESTED:
for my $i ( reverse 0 .. $#{ $self->{ trolley } } )
In reply to Re^3: [RFC] Module code and POD for CPAN
by jwkrahn
in thread [RFC] Module code and POD for CPAN
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |