in reply to Re: self-referent hash for your packages
in thread self-referent hash for your packages

I'll expand on that a bit...

The syntax for dereferencing a hash reference is identical whether the reference is a symbolic reference (a string that names a global variable) or a real reference ("hard reference"). So if -> works on real references to hashes, then it also works on symbolic references to hashes (that is, on strings).

You avoid using symbolic references by saying use strict. You don't avoid using symbolic references by avoiding certain types of dereferencing syntax.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: self-referent hash for your packages
by princepawn (Parson) on Nov 03, 2001 at 04:49 UTC
    a symbolic reference (a string that names a global variable) ... You avoid using symbolic references by saying use strict.
    If you look at my code, I did use strict

      True, use strict "refs"; doesn't catch the use of symbolic references via string literals (that is, strings that are compile-time constants). __PACKAGE__ expands to be a string literal.

      use strict "refs"; adds run-time checks to make sure that you don't dereference a variable that you expected to contain a real reference but that actually contained something else. Since there is no way for __PACKAGE__ to be a real reference, it sort of makes sense for use strict "refs"; to not disallow dereferencing it. Or you could consider this a bug in strict's implementation.

      So I guess I should update what I said from "You don't avoid using symbolic references by avoiding certain types of dereferencing syntax." to this:

      You don't avoid using symbolic references by avoiding certain types of dereferencing syntax, but you will need to avoid using certain types "hard-coded" references.

      I had forgotten about this quirk of strict.

              - tye (but my friends call me "Tye")