On Thu, 03 Aug 2000 17:57:45 +0100, Hildo Biersma wrote:
>I have had a need for symbolic references - unless you want to do 'eval'
>which could be worse...
There is a way do symbolic references without actual using symbolic
references: direct access of the typeglobs through the stashes.
$Foo::bar
is equivalent to
${$::{'Foo::'}->{'bar'}}
or
${*::->{'Foo::'}->{'bar'}}
Two caveats:
A) Perl currently has a weird implementation of "nested" packages:
although nested packages don't really exist (all packages are side by
side), yet, Perl implements them that way. For example, a typeglob
*Foo::Bar::Baz::fred can be accessed through:
*::->{'Foo::'}->{'Bar::'}->{'Baz::'}->{'fred'}
Why it's not simply
$::{'Foo::Bar::Baz::'}->{'fred'}
is beyond me. Anyway, to get at variables in nested packages, in
general, you'll need a loop.
B) Importing through this mechanism fails to fool "strict". Although
variables can be set, and aliases be made, "strict" will still complain
about these variables.
In short: I would love it if symbolic references not only used a
different syntax from plain references, but the fact that the same code
can be used both for actual and for symbolic references (without
'strict') annoys the sh*t out of me. Symbolic references ought to be
difficult to accomplish, 'strict' or not.
But: if typeglobs (and stashes?) are to go, so would this potential
replacement.
--
Bart.