3 ms·
Hmmm... perldoc.perl.org doesn't have 5.14 as an option yet. I assume that the 'r' option is meant to prevent things like this: my @list = (... stuff ...);
by pyre 16y ago
Hmmm... perldoc.perl.org doesn't have 5.14 as an option yet. I assume that the 'r' option is meant to prevent things like this:
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.)
- tedreed 16y agoThat's exactly why. (Incidentally, perlcritic will warn you if you have a map that modifies $_.)
- simcop2387 16y agoAlong with that, it's also for doing things like 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.