Perl esoterica: getting variable's name as string value

by David Mintz <mambomintz(at)yahoo.com>

 Date:  Thu, 26 Apr 2001 12:26:37 -0700 (PDT)
 To:  hwg-languages(at)hwg.org
 In-Reply-To:  h8j8r3
  todo: View Thread, Original
Suppose you have this:

my %Homer = (
   body_type => 'fat',
   favorite_beverage=>'beer',
   memorable_quote =>"D'oh!"
);

and you want to get a string containing the name of
this hash, i.e., "Homer"?

FWIW, what I have in mind is writing functions for
creating form elements and validating input. I want to
pass my function a hash reference whose referent is a
hash containing the attributes of, say, a textfield --
size, default value, maxlength, and... name! It sticks
in my throat to do this, it's so inelegant:

my %Homer = (
   name => 'Homer'
   # etc
);

Thanks,

David Mintz
Spanish Interpreter
US District Court, SDNY
Personal http://panix.com/~dmintz/
Web design & hosting http://dmintzweb.com/

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA