my @arr = qw/foo bar baz quack/; for (@arr) { print $_, "\n"; shift @arr if $_ eq "bar"; }