in reply to Re: Hash as Hash Value
in thread Hash as Hash Value

When you write $hashOfUsers{$someKey}{UID}, perl automatically rewrites it internally as $hashOfUsers{$someKey}->{UID}, using The Arrow Operator to dereference. This is then interpreted as:

  1. Get the value from the hash %hashOfUsers corresponding to $someKey
  2. deference it as a hash (->{}) and
  3. get the key associated with UID."

If $hashOfUsers is a hashref and you want to access that, you want the syntax $hashOfUsers->{$someKey}{UID}. Perl can't automatically know to deference $hashOfUsers because then $hashOfUsers{$someKey} would be ambiguous in the case where you had both a hash and a scalar named hashOfUsers. It can automatically deference the second bracket since the syntax is unambiguous.