in reply to Getting a Hash Name

Maybe it's not sexy and it's a bit simple but why don't you just var the name and then pass it through, like:

my $name = "HASH"; my %$name = ( one => 1, two => 2 ); check_limit($name); sub check_limit { my ($hname) = $_[0]; my $num = 0; for (keys %{$hname}) { $num++ }; print "Hash: $hname has $num keys\n"; }


I've done similar things on very long pieces of code for debugging purposes...

magnus

Replies are listed 'Best First'.
Re^2: Getting a Hash Name
by chromatic (Archbishop) on Jul 04, 2005 at 20:26 UTC

    Why not? Because it doesn't pass strict, which can be a problem with longer programs. Having global variables pop in and out of existence is difficult to debug.