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

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

by tianping (Initiate)
on Jun 02, 2011 at 08:40 UTC ( #907767=categorized answer: print w/replies, xml ) Need Help??

Q&A > references > How do I take a slice of a hash reference? - Answer 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};

Log In?

What's my password?
Create A New User
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2017-05-28 05:38 GMT
Find Nodes?
    Voting Booth?