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

Why does ‘keys’ need a named hash?

by ankitpati (Sexton)
on Apr 05, 2017 at 11:55 UTC ( [id://1187094]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
            sub uniq {
                my %hash = map { $_ => 1 } @_;
                return keys %hash;
            }
    
  2. or download this
            sub uniq {
                return keys map { $_ => 1 } @_;
            }
    
  3. or download this
            sub uniq {
                # two pairs of braces around map
                return keys %{ { map { $_ => 1 } @_ } };
            }
    
  4. or download this
            sub uniq {
                # single pair of braces around map
                return keys %{ map { $_ => 1 } @_ };
            }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1187094]
Approved by 1nickt
Front-paged by 1nickt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found