in reply to Re: Variable Names and References
in thread Variable Names and References
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):# or: my $ref = "str$_"; # this is a purely symbolic reference, +access is the same as above
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.my $class = 'CGI'; my $version; { no strict 'refs'; $version = ${"${class}::VERSION"}; use strict; } print $version # e.g. 3.05 on my machine
...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 |
In Section
Seekers of Perl Wisdom