Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: symboltable problem

by Eliya (Vicar)
on Jun 20, 2012 at 21:26 UTC ( #977476=note: print w/replies, xml ) Need Help??


in reply to Re^2: symboltable problem
in thread symboltable problem

I think the problem is that %Bubba:: = %Hubba:: is creating a new hash, which destroys the binding of $Bubba::abba to the original hash set up at compile time of the latter expression.  This reasoning is based on the observation that both of the following work fine:

#!/usr/bin/perl use strict; $Hubba::abba = "zappa\n"; %Bubba:: = %Hubba::; # compile time deferred eval 'print $Bubba::abba';
#!/usr/bin/perl use strict; $Hubba::abba = "zappa\n"; # copying via hash slice doesn't create new hash @Bubba::{keys %Hubba::} = @Hubba::{keys %Hubba::}; # or: @Bubba::{keys %Hubba::} = values %Hubba::; print $Bubba::abba;

Replies are listed 'Best First'.
Re^4: symboltable problem
by choroba (Chancellor) on Jun 20, 2012 at 21:55 UTC
    Yes, that seems to eplain it. Another solution then is to create the alias in a BEGIN block.
Re^4: symboltable problem
by morgon (Curate) on Jun 21, 2012 at 16:00 UTC
    Thanks - that is very interesting. I did not expect that...

    I find this illustration quite amusing:

    use strict; our $foo = "old value\n"; %:: = (%::); our $var = "new value\n"; $::{foo} = *var; print $foo; eval q| print $foo |;
    btw: Is there a nicer way to create a typeglob with a given value in the scalar-slot?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://977476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2016-09-26 15:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (483 votes). Check out past polls.