in reply to Unforseen OO conducts
It has nothing to do with OO. Or bless. Or hashes. Or even references.
If you do this:
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.$var2 = "foo"; $var1 = $var2; $var2 = "bar"; print $var1;
If you want to get at the current value of a variable, store a reference to that value.
(Fixed typo pointed to by thor)$var2 = "foo"; $var1 = \$var2; $var2 = "bar"; print $$var1; # Prints "bar", not "foo".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unforseen OO conducts
by thor (Priest) on Oct 06, 2005 at 13:23 UTC | |
by Perl Mouse (Chaplain) on Oct 06, 2005 at 13:27 UTC |