i always use strict but got not no complaints as perl took it as a hash, not a reference, but i remembered it would somehow work without arrows, like this
my $crd = ${$ref}{$key}{NAME};
| [reply] [d/l] |
$ref{$key}{NAME} and ${$ref}{$key}{NAME} are two completely different things. But you can say that the latter is another form of arrow notation (the first arrow, because it's a dereference operator), so they are both a hash reference.
my $env = \%ENV;
print $env->{SHELL};
print ${$env}{SHELL};
print $env{SHELL}; # barks under strict, undefined otherwise
# output:
/bin/bash
/bin/bash
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
| [reply] [d/l] [select] |
The two lookups $ref->{$key} and $ref{$key} access two different variables. They are not interchangeable, and the -> is not optional.
$ref->{$key} looks up the $key key in the $ref hashref.
$ref{$key} looks up the $key key in the %ref hash.
| [reply] [d/l] [select] |
That is not the same thing. $ref->{$key}{NAME} uses a hash reference stored in the scalar variable $ref, whereas $ref{$key}{NAME} uses a hash stored in the hash variable %ref.
| [reply] [d/l] [select] |