by pyre · 15y ago · 0 comments
my @list = (... stuff ...);
my @other_list = map { s/SOMETHING//; $_ } @list;
(The result of this is that @other_list and @list are equal because the substitution destructively affects the original list.)(Incidentally, perlcritic will warn you if you have a map that modifies $_.)
my $old = "foo"; my $new = $old =~ s/foo/bar/r;
$old still contains "foo" and $new contains "bar", but inside a map should be great as well.