in reply to Unforseen OO conducts

The OO part in your topic is a red herring.

It has nothing to do with OO. Or bless. Or hashes. Or even references.

If you do this:

$var2 = "foo"; $var1 = $var2; $var2 = "bar"; print $var1;
Do you expect it to print "bar"? It won't, and shouldn't. If you replace in the above code $var2 with $object->{a}->{var2}, $var1 with $object->{b}->{var1}, "foo" with bless {}, "A1"; and "bar" with $dummy, you get what you are doing.

If you want to get at the current value of a variable, store a reference to that value.

$var2 = "foo"; $var1 = \$var2; $var2 = "bar"; print $$var1; # Prints "bar", not "foo".
(Fixed typo pointed to by thor)
Perl --((8:>*

Replies are listed 'Best First'.
Re^2: Unforseen OO conducts
by thor (Priest) on Oct 06, 2005 at 13:23 UTC
    Do you expect it to print "bar"? It won't, and shouldn't.
    It does and it should. :) Perhaps you have a typo in your code and meant something else...

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      I first had the roles for $var1 and $var2 reversed, but changed them to match the use of {var1} and {var2} by the OP. But I forgot to update the variable used in the print statement.

      Thanks.

      Perl --((8:>*