Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by BillKSmith (Monsignor)
on Apr 05, 2017 at 15:16 UTC ( [id://1187137]=note: print w/replies, xml ) Need Help??


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

The document is using the word "named" in the sense of "specified in the calling statement". You can take the keys of an anonymous hash:
use strict; use warnings; my @Uniq = uniq('a', 'b', 'c', 'a', 'b', 'a'); print "@Uniq\n"; sub uniq { return keys %{{map {$_=>1} @_}}; } OUTPUT: c a b

Edit: Revised example to be more like the original problem.

Bill

Log In?
Username:
Password:

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

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

    No recent polls found