The contents of $#{ ... } must be an expression that returns a reference or a variable name (aka symbolic reference).
$#{ @array } was buggy in the past — it was treated as $#{ \@array } — but it was fixed to work as documented. You were apparently relying on this bug. The correct usage is
$#{ $ref }
or simply.
$#$ref
Note the parallels:
$array[$i] ${ $ref }[$i] (also $ref->[$i]) @array @{ $ref } $#array $#{ $ref }
Ref:
Dereferencing Syntax
References Quick Reference
But when I ran the code that does this in perl 5.10.1, it returns -1 for $#{@{$a}}.
You should have gotten
Can't use string ("0") as an ARRAY ref while "strict refs" in use.
Don't hide errors. Use «use strict; use warnings;»!
In reply to Re: Perl 5.10.1 versus 5.8.8 with $#{}
by ikegami
in thread Perl 5.10.1 versus 5.8.8 with $#{}
by dirko.van.schalkwyk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |