Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How do I take a slice of a hash reference?

by tianping (Initiate)
on Jun 02, 2011 at 08:40 UTC ( [id://907767]=note: print w/replies, xml ) Need Help??


in reply to How do I take a slice of a hash reference?

japhy has answered the question, but it's also worth pointing out the solution to the syntax error in your original code. The parentheses alter the priority; so just remove them:
print join ':', @$hash{1,2};
More generally, put curly braces around the hash ref expression:
print join ':', @{$hash}{1,2};

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://907767]
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: (4)
As of 2024-04-23 06:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found