Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by duelafn (Vicar)
on Apr 05, 2017 at 12:04 UTC ( #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
Node Status?
node history
Node Type: note [id://1187096]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-02-27 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?