in reply to Is there any way to find the name of a tied variable?
Here we have the *names* 'x' and 'y' pointing to the same value.. It doesn't make sense in this instance for the value to know what its name is, because it has more than one (could have used an anon hash, in which case it would have no Name at all).#!/usr/bin/perl -wT use strict; my $x = {name => 'x', value => 123}; my $y = $x; $y->{name} = 'y'; $y->{value} = 321; print "X: $x->{name} => $x->{value}\n"; print "Y: $y->{name} => $y->{value}\n"; =output X: y => 321 Y: y => 321
In general I think its a bad idea to attempt to replicate the name of the variable in the contents of the variable. However, I haven't done much Tie:: development (used them a bunch, but haven't spent much time under the hood) so take my advice in the more general sense.
-Blake
|
|---|