while (@array) { my $val = shift @array; # do something with $val }