# ------------------ # FIRST ALTERNATIVE: @out_list = @in_list; map { s/foo(.*?)bar/$1 baz/ } @out_list; # ACK!! ARRGGHH!! map in void context! how bad is that? # (Well, seriously: how bad _is_ that, compared to the # other alternatives below? But let's not digress...) # ------------------- # SECOND ALTERNATIVE: @out_list = map { s/foo(.*?)bar/$1 baz/ } split /\x0/, join("\x0",@in_list); # okay, map is used "correctly", and this even works when # the input list and block processing are numeric, but... # seems like too much busy-work just to protect @input_list # from being altered by map. # ------------------ # THIRD ALTERNATIVE: @out_list = map {$j=$_; $j=~s/foo(.*?)bar/$1 baz/; $j} @in_list; # at this point, might as well use "foreach (@input_list) {...}" instead