my $i = 0; while ($i <= $#foo) { push @foo, 'h' if $foo[$i] eq 'd'; print $foo[$i]; $i++; }