in reply to printing refence of hash inside a hash

The following is a bit carried away but I think it might be usefull one way or the other.

As far as I know

foreach (keys %$data ) { bla....

causes $data to be deferenced on each iteration of the loop, which may become expensive if you have a huge amount of stuff in $data

One may extract the keys before the loop, use a temporary array which will be used for the loop (and while freeing resources) like this:

my @tmp_ary = keys %$data; while(my $item = shift @tmp_ary) { do stuff... }
After the loop @tmp_ary will still be there but empty.

Hope this helps
RL