[perl #117531] Deparse elements of %# correctly

They can only be referred to as $# {foo} and ${#}{foo}, not as $#{foo},
as that means $#foo.
This commit is contained in:
Father Chrysostomos 2013-06-03 21:57:33 -07:00
parent 9b12f83b0b
commit bcbe2b27bd
2 changed files with 6 additions and 1 deletions

View File

@ -3515,7 +3515,9 @@ sub elem {
}
if (my $array_name=$self->elem_or_slice_array_name
($array, $left, $padname, 1)) {
return ($array_name =~ /->\z/ ? $array_name : "\$" . $array_name)
return ($array_name =~ /->\z/
? $array_name
: $array_name eq '#' ? '${#}' : "\$" . $array_name)
. $left . $idx . $right;
} else {
# $x[20][3]{hi} or expr->[20]

View File

@ -1410,3 +1410,6 @@ use feature 'state', 'lexical_subs';
no warnings 'experimental::lexical_subs';
state sub f {}
print f();
####
# Elements of %# should not be confused with $#{ array }
() = ${#}{'foo'};