in reply to Perl::Critic says don't modify $_ in list functions and other things
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 { $_ = ...; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl::Critic says don't modify $_ in list functions and other things
by hippo (Archbishop) 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 |