Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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 ( #11119076=note: print w/replies, xml ) Need Help??


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

I hope Im not being obtuse and about to embarrass myself but

# Why this? my @b = apply { $_ = uc($_);} @a; # Instead of this, or a more verbose version of it? my @b = map uc, @a;
  • Comment on Re^2: Perl::Critic says don't modify $_ in list functions and other things
  • Download Code

Replies are listed 'Best First'.
Re^3: Perl::Critic says don't modify $_ in list functions and other things
by AnomalousMonk (Bishop) on Jul 09, 2020 at 14:34 UTC

    I'll take the liberty of answering for ikegami and guess that
        my @b = apply { $_ = uc($_);} @a;
    is just a quick example of the use of apply put together to be consistent with the preceding code
        my @b = map { $_ = uc($_); $_ } @a;
    which was itself just a quick example put together to demonstrate a particular problem. I'd be very surprised if ikegami suggested it | either for production code.


    Give a man a fish:  <%-{-{-{-<

Re^3: Perl::Critic says don't modify $_ in list functions and other things
by ikegami (Pope) on Jul 12, 2020 at 14:40 UTC

    Of course, but the OP isn't actually using $_ = uc($_), and your solution wouldn't help the OP. $_ = uc($_) is just a placeholder for a large block of code that possibly modifies $_.

Log In?
Username:
Password:

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

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