http://qs321.pair.com?node_id=604266


in reply to Re: Variable Names and References
in thread Variable Names and References

# or: my $ref = "str$_"; # this is a purely symbolic reference, +access is the same as above
I don't see how that is a symbolic reference? I think this is (had to think a while to come up with something contrived, here):
my $class = 'CGI'; my $version; { no strict 'refs'; $version = ${"${class}::VERSION"}; use strict; } print $version # e.g. 3.05 on my machine
In other words, we construct a variable's name ($CGI::VERSION) out of expanded variables ($class), and expand (it's almost like a string eval()) the result in turn to return the value stored under the constructed variable's name.

...mmmm still not really put elegantly, sorry.

Replies are listed 'Best First'.
Re^3: Variable Names and References
by Joost (Canon) on Mar 12, 2007 at 10:25 UTC
    Symbolic references are just names of global variables. That means "str2" is a symolic reference, just like "CGI::VERSION" is.

    In other words; "${class}::VERSION"; is a symbolic reference, and ${"${class}::VERSION"}; derefences the reference into the value of $CGI::VERSION. Note that "hard" references use exactly the same syntax to dereference.