in reply to Perl::Critic says don't modify $_ in list functions and other things
Sometimes, no loop is needed at all:
chomp( my @list = <$fh> );
When using readline, it's probably not so serious, as you aren't changing the original array in place at the same time.
The /r is useful when you want to keep the original:
my @ids = map s/ /_/gr, grep defined, @base;
When you want to modify the original array, use "for" instead.
for (@$list) { if (ref) { ... } else { $_ = ...; } }
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl::Critic says don't modify $_ in list functions and other things
by hippo (Bishop) on Jul 09, 2020 at 08:33 UTC | |
by Bod (Parson) on Nov 19, 2020 at 17:38 UTC | |
by marto (Cardinal) on Nov 19, 2020 at 17:52 UTC | |
by Bod (Parson) on Nov 19, 2020 at 17:56 UTC |
In Section
Seekers of Perl Wisdom