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

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

( #907767=categorized answer: print w/ replies, xml ) Need Help??

Q&A > references > How do I take a slice of a hash reference? contributed by tianping

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};

Comment on Answer: How do I take a slice of a hash reference?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2014-08-28 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls