Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Fixing: Experimental keys on scalar is now forbidden

by kennethk (Abbot)
on Jun 06, 2018 at 14:42 UTC ( #1216031=note: print w/replies, xml ) Need Help??


in reply to Re: Fixing: Experimental keys on scalar is now forbidden
in thread Fixing: Experimental keys on scalar is now forbidden

I agree with the "Better yet," but in situations where I do something like option 1, I like to wrap it in a do block to maintain tight scoping:
my @uniqWebCustomers = do{ my %seen; grep !$seen{$_}++, @webCustomers; };

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^3: Fixing: Experimental keys on scalar is now forbidden
by ikegami (Pope) on Jun 07, 2018 at 01:42 UTC

    If you're going to add a block, make it a sub.

    sub uniq { my %seen; grep !$seen{$_}++, @_ } my @uniqWebCustomers = uniq @webCustomers;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2020-10-23 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (236 votes). Check out past polls.

    Notices?