develooper Front page | perl.perl5.porters | Postings from April 2010

[perl #5249] Symbol table aliasing not DWIM'ing except under Debugger

Thread Previous | Thread Next
From:
Eric Brine via RT
Date:
April 30, 2010 01:42
Subject:
[perl #5249] Symbol table aliasing not DWIM'ing except under Debugger
Message ID:
rt-3.6.HEAD-27388-1272564323-699.5249-15-0@perl.org
It has nothing to do with the debugger. Anything that delays compilation
until after the aliasing is done will suffice.

Apparently, the "$g::var" in "print $g::var" is resolved at compile-time.

----- BEGIN CODE -----
$foo::bar::poit::var = "fbp";
$g::var              = "g";
BEGIN {
$h::var              = "h";
}

*g:: = \%foo::bar::poit::;  # Alias g:: to some long thing.
BEGIN {
*h:: = \%foo::bar::poit::;  # Alias h:: to some long thing.
}

print "$foo::bar::poit::var\n";  # Prints fbp
print "$g::var\n";               # Prints g
print "$h::var\n";               # Prints fbp

eval '
print "$foo::bar::poit::var\n";  # Prints fbp
print "$g::var\n";;              # Prints fbp
print "$h::var\n";;              # Prints fbp
';
----- END CODE -----


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About