#!/usr/bin/perl -w use strict; my @list = ( 1, 2, 3, 'foo', 4, 'bar' ); $_ = 1; foreach (@list) { print "$_\n"; } print "between loops: $_\n"; while (shift @list) { print "$_\n"; } print "after loops: $_\n"; shift @list; shift @list; shift @list; print "$_\n"; #we are expecting 3, but it's really 1.