<?xml version="1.0" encoding="windows-1252"?>
<node id="80399" title="How do I take a slice of a hash reference?" created="2001-05-14 23:17:02" updated="2005-08-11 06:05:20">
<type id="1857">
categorized question</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
&lt;!-- I [jdporter] RECOMMEND THIS CatQ for SOPWIFICATION! (but delete this comment first!) --&gt;

I can take a slice of an array ref, but not of a hash ref:&lt;br&gt;
&lt;code&gt;
my $arr =[1,'a',2,'b'];
my $hash={1,'a',2,'b'};
print join ':',(@$arr )[1,2];
print join ':',(@$hash){1,2};
&lt;/code&gt;
The first print statement works, the second is a syntax error.  I also have this problem when taking a slice of an anonymous hash:
&lt;code&gt;
print join ':',(1,'a',2,'b')[1,2];
print join ':',(1,'a',2,'b'){1,2};
&lt;/code&gt;
Again, the first statement works, but the second is a syntax error.</field>
<field name="parent_node">
1832</field>
</data>
</node>
