use Data::Dumper; @array = 0 ... 9; foreach $item (@array) { print ++$i . " through the loop\n"; $item = pop @array; print Dumper(\@array); }