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:
More generally, put curly braces around the hash ref expression:print join ':', @$hash{1,2};
print join ':', @{$hash}{1,2};
|
---|
In Section
Seekers of Perl Wisdom