in reply to Is there any way to find the name of a tied variable?

One problem is you aren't even tying $tree to begin with, you are tying %x, and then assigning the object ref to $tree. But I do not think there is any way to do this... nor should you really want to... root is very dscriptive or the top node of a tree (or bottom node bdepending on how you look at it)

You could probably do something along the lines of the followi ng...

use Tie::HashTree qw(hash_to_tree); #my $tree = tie my %x, 'Tie::HashTree'; Tie::HashTree->new('tree'); sub new { my $pkg = shift; my($ppackage) = (caller)[0]; ${$ppackage.'::'.$_[0]} = tie %{$ppackage.'::'.$_[0]}, $pkg; } sub TIEHASH { my ($class, $self) = @_; $self->{level} = ""; $self->{name} = "top"; $self->{top} = {}; bless ($self, $class); }
Now, you will probably have to turn off strict and warnings inside the new()... but it will work (I sort of tested it) but it is probably a bad idea, and you should probably just either keep the same name for all, or have them pass it in. However, don't ever say you weren't enlightened to the dark corners of perl ;-) TIMTOWTDI

Update BTW - the new func ties and saves to $tree and %tree in the package it was called from

                - Ant
                - Some of my best work - Fish Dinner