in reply to Getting a Hash Name

One of the problems I see with this kind of reflection is that one hash could have more than one name if you create aliases using GLOBs:
my *otherName = %hash1;
If you pay the maximum attention, you could pass the name of the hash as a scalar string, then use eval variable name dereferencing (like %$name, as pointed out below by others) inside check_limit to access the actual hash. Did I already say that you have to carefully check every implication of such an approach?

Update: I realised that eval is overkill in this case, a simple %$name will do as suggested by others. Nonetheless, this must not be an excuse to drop a careful approach.

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: Getting a Hash Name
by Thilosophy (Curate) on Jul 04, 2005 at 12:19 UTC
    One of the problems I see with this kind of reflection is that one hash could have more than one name

    Moreover, it does not even need to have a name at all:

    check_limit({ one => 1, two =>2 });