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

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

Thread Previous
From:
Alexandr Ciornii via RT
Date:
April 29, 2010 07:28
Subject:
[perl #5249] Symbol table aliasing not DWIM'ing except under Debugger
Message ID:
rt-3.6.HEAD-27388-1272551321-1262.5249-14-0@perl.org
Same result on 5.12.0.

On Thu Jan 18 04:09:13 2001, clintp wrote:
> I have a package with a very, very long name and many varibles
> that I want to address within the package.  I'd like to alias the
> entire namespace.  I recall doing something like this in older
> Perls:
> 
> $foo::bar::poit::var="hlaghlag";
> *g::=\%foo::bar::poit::;   # Alias g:: to some long thing.
> print $g::var;             # Should print hlaghlag
> 
> Someone else remembered being able to do this as well, so I don't
> think I'm completely senile.   It doesn't work now.  Explanation:
> 
> Anyways, in the debugger I can dump g's symbol table and it shows
> $var is there.  And I can print $g::var at a debugger prompt, and it's
> there.  Actually trying to use $g::var in the body of the program
> yields undef.
> 
> main::(foo.pl:4):       $foo::bar::poit::var="hlag";
>   DB<1> n
> main::(foo.pl:5):       *g::=\%foo::bar::poit::;
>   DB<1> n
> main::(foo.pl:6):       print $g::var, "\n";
>   DB<1> V g
> $var = 'hlag'            # It's there!
>   DB<2> print $g::var
> hlag                     # No, really!  It's there!
>   DB<3> n
>             # <--- hlag should have printed, It's gone!
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> 
> This is under perl 5.6 and perl5.005.  At the very least, it's
> confusing
> and not very DWIM'ish.

-- 
Alexandr Ciornii, http://chorny.net


Thread Previous


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