Contrary to what you say, both
@$hr{a} = "hello"; # Hash slice. Equiv to @h[0].
and
@$ar[0] = "hello"; # Array slice. Equiv to @a[0].
work for me, as they should.
ActivePerl v5.6.1 Win2k
ActivePerl v5.8.0 WinXP
perl v5.8.0 FreeBSD
It's true that %$hr{a} doesn't work, but why should it? It would be equivalent to %h{a} which is not valid Perl.
Of course, I don't know what you're using slices with just one element. The following work just as great:
$$hr{a} = "hello"; # Same as $hr->{a}. Equiv to $h{a}.
and
$$ar[0] = "hello"; # Same as $ar->[0]. Equiv to $a[0].
Update: Added to the node.
In reply to Re: A better understanding of array and hash references
by ikegami
in thread A better understanding of array and hash references
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |