in reply to Perl::Critic says don't modify $_ in list functions and other things
Here's the problem with your approach:
my @a = qw( a b c ); my @b = map { $_ = uc($_); $_ } @a; say "@a"; # A B C <-- You clobbered @a!!! say "@b"; # A B C
Use List::MoreUtils's apply instead of map.
my @a = qw( a b c ); my @b = apply { $_ = uc($_);} @a; say "@a"; # a b c say "@b"; # A B C
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl::Critic says don't modify $_ in list functions and other things
by Your Mother (Archbishop) on Jul 09, 2020 at 08:40 UTC | |
by AnomalousMonk (Archbishop) on Jul 09, 2020 at 14:34 UTC | |
by ikegami (Patriarch) on Jul 12, 2020 at 14:40 UTC |