in reply to Re^2: Assigning value through references
in thread Assigning value through references

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^4: Assigning value through references
by Prof Vince (Friar) on Oct 09, 2007 at 08:15 UTC
    No, not under strict.
      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};
        $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!

Re^4: Assigning value through references
by Somni (Friar) on Oct 09, 2007 at 08:55 UTC

    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.

Re^4: Assigning value through references
by dah (Sexton) on Oct 09, 2007 at 09:01 UTC
    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.