in reply to Re: Perl oddities (s/// doesn't DWIM in map)
in thread Perl oddities
If map couldn't modify its input, the whole "map in a void context" debate might never have happened. for would be used for modifying input, map would be used for generating new output. Of course, it's a tradeoff, giving up some liberty for safety.my @new = map { s/foo/bar/; $_ } @old; # @old is modified along with @new! # should be my @new = map { s/foo/bar/; $_ } map {$_} @old;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Perl oddities (s/// doesn't DWIM in map)
by ikegami (Patriarch) on Mar 01, 2005 at 22:59 UTC | |
Re^3: Perl oddities (s/// doesn't DWIM in map)
by Aristotle (Chancellor) on Nov 19, 2005 at 09:02 UTC |