Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by ikegami (Pope)
on Jul 09, 2020 at 03:03 UTC ( #11119060=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @a = qw( a b c );
    my @b = map { $_ = uc($_); $_ } @a;
    say "@a";  # A B C     <-- You clobbered @a!!!
    say "@b";  # A B C
    
  2. or download this
    my @a = qw( a b c );
    my @b = apply { $_ = uc($_);} @a;
    say "@a";  # a b c
    say "@b";  # A B C
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-01-23 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?