use strict; use warnings; my @foo = qw/a b c d e f g/; foreach my $x (@foo) { push @foo, 'h' if $x eq 'd'; print "$x"; }