Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl::Critic says don't modify $_ in list functions and other things

by Lady_Aleena (Curate)
on Jul 09, 2020 at 19:08 UTC ( #11119106=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      my @list       = map { chomp($_); $_ } <$fh>;
      my @uc_list    = map { chomp $_; [uc $_] } <$lc_fh>; # used only onc
    +e
      my @split_list = map { chomp $_; [ split(/\|/, $_) ] } <$piped_fh>; 
    +# used only once
    
  2. or download this
      my @list       = map { chomp; $_ } <$fh>;
      my @uc_list    = map { chomp; [uc $_] } <$lc_fh>; # used only once
      my @split_list = map { chomp; [ split(/\|/, $_) ] } <$piped_fh>; # u
    +sed only once
    
  3. or download this
      my @array = map {
        $_ =~ s/^[\*\+-] (.+)/$1/;
        some_sub($_, $opt);
      } @another_array;
    
  4. or download this
    <code>
      my @array = map {
        some_sub($_, $opt);
      } @another_array;
    
  5. or download this
      my @ids = map {
        $_ =~ s/<.+?>//g;
    ...
        $_ =~ s/[^\w:.\-]//g;
        $_;
      } grep {defined($_)} @base;
    
  6. or download this
      my @ids = map {
           s/<.+?>//gr
    ...
        =~ s/ /_/gr
        =~ s/[^\w:.\-]//gr
      } grep { defined } @base;
    
  7. or download this
    sub fancy_map {
      my ($opt, $list) = @_;
    ...
        }
      } @{$list};
    }
    
  8. or download this
    sub fancy_map {
      my ($opt, $list) = @_;
    ...
          }
      } @{$list};
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-01-23 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?