morgon has asked for the wisdom of the Perl Monks concerning the following question:
I would like to understand why the following script does not behave as expected.
In the script I had expected that $Bubba::abba would become an alias for $Hubba::abba, but that does not seem to be the case - so evidently %Bubba:: = %Hubba:: is not doing what I thought it would do....
Can someone explain the behaviour to me?
use strict; use Data::Dumper; # put something in package "Hubba" $Hubba::abba = "zappa\n"; # assign Hubba-symtable to Bubba-symtable %Bubba:: = %Hubba::; # verify that they are the same print Dumper(\%Hubba::); print Dumper(\%Bubba::); # use 2 ways to print $abba from Hubba print ${*Hubba::abba{SCALAR}}; # works print $Hubba::abba; # works print "and now Bubba:\n"; print ${*Bubba::abba{SCALAR}}; # prints nothing print $Bubba::abba; # print nothing
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: symboltable problem
by Anonymous Monk on Jun 20, 2012 at 17:31 UTC | |
by morgon (Priest) on Jun 20, 2012 at 17:37 UTC | |
by Anonymous Monk on Jun 20, 2012 at 17:54 UTC | |
Re: symboltable problem
by Anonymous Monk on Jun 20, 2012 at 18:00 UTC | |
by morgon (Priest) on Jun 20, 2012 at 19:22 UTC | |
by Eliya (Vicar) on Jun 20, 2012 at 21:26 UTC | |
by choroba (Cardinal) on Jun 20, 2012 at 21:55 UTC | |
by morgon (Priest) on Jun 21, 2012 at 16:00 UTC |