Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Why does 'keys' need a named hash?

by duelafn (Parson)
on Apr 05, 2017 at 12:04 UTC ( [id://1187096]=note: print w/replies, xml ) Need Help??


in reply to Why does ‘keys’ need a named hash?

It needs a real hash to work on (possibly there is a more technical description of this), but the map just produces a list of values, not a hash.

You can do it all in one line though:

use 5.010; sub uniq { return keys %{ {map { $_ => 1 } @_} }; } say for uniq qw/ foo bar foo baz bip foo /;

Good Day,
    Dean

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-23 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found