in reply to dereference references in an array

Also note here the use of a doubled dollar-sign, e.g. $$varname, as a legitimate and somewhat more-succinct alternative to the use of the -> dereference operator.   (Dunno, it might be the only one that works given this particular use of map.)   I happen to prefer it, and do use it often ...

Replies are listed 'Best First'.
Re^2: dereference references in an array
by Anonymous Monk on Sep 02, 2014 at 08:37 UTC

    Just a note from perlref because people make this mistake:

    ... $$arrayref[0] = "January"; $$hashref{"KEY"} = "VALUE";

    It's important to understand that we are specifically not dereferencing $arrayref[0] or $hashref{"KEY"} there. The dereference of the scalar variable happens before it does any key lookups. ...

    Because of being able to omit the curlies for the simple case of $$x, people often make the mistake of viewing the dereferencing symbols as proper operators, and wonder about their precedence. If they were, though, you could use parentheses instead of braces. That's not the case.