while (@foo) { my $x = shift @foo; push @foo, 'h' if whatever(); }