Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: What is %_

by LanX (Saint)
on Sep 29, 2015 at 20:38 UTC ( [id://1143368]=note: print w/replies, xml ) Need Help??


in reply to Re: What is %_
in thread What is %_

> It's neat because it's self contained. Although it does seem to leave some namespace pollution as a result

If you want to use this "unique" construction multiple times, it'll break if you don't clean up %_ afterwards.

So its neat for a one liner, in every other situation I'd rather prefer an explicit my %seen or importing uniq from List::MoreUtils .

update

Btw your code does nothing, you forgot the ++ part.

@list = grep { !$_{$_}++ } @list;

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-04-18 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found