Hash keys are evaluated in scalar context. @something (including @{expr}) returns the number of elements in @something when evaluated in scalar context.
$monthhash{@$month[0]}
should be
$monthhash{$month->[0]}
if you want the first element of @$month to be used as the key.
By the way,
$month->[0]
can also be written as
${$month}[0]
and
$$month[0]
but they're less readable.
Update: Oops! Array slices, such as @something[0] and @{expr}[0] do *not* return a number of elements in scalar context. You're needlessly using array slices, but that's not your problem. While $monthhash{$month->[0]} would be better, it won't fix anything.
In reply to Re: Using array value (from array ref) as hash key??
by ikegami
in thread Using array value (from array ref) as hash key??
by Haddock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |