my @foo = qw/a b c d e f g/; for my $x (@foo) { push @foo, 'd' if $x eq 'd'; print $x; } #### push @foo, map {$_ eq 'd' ? 'd' : ()} @foo; print for @foo; #### for (@foo) { print; shift(@foo) if $_ eq 'c'; } print "\n@foo\n";
## push @foo, map {$_ eq 'd' ? 'd' : ()} @foo; print for @foo; ##
## for (@foo) { print; shift(@foo) if $_ eq 'c'; } print "\n@foo\n";