> -----Original Message-----
> From: jshock [mailto:[EMAIL PROTECTED] 
> Sent: Monday, May 19, 2008 07:20
> To: beginners@perl.org
> Subject: How do I find the key of a specific hash element?
> 
> For example:
> 
> my %weekdays = (
>       0  => "SUN",
>       1 => "MON",
>       2 => "TUE",
>       3 => "WED",
>       4 => "THU",
>       5 => "FRI",
>       6 => "SAT",
> );
> $weekdays{2}; # gives "TUE"
> 
> But what if I know "TUE" and want to find out what the key is? Is
> there a construct like $weekdays{"TUE"} that gives 2"
> 
        It depends on what information you will have and how big and how
often will you need to access that data. You can either search the
weekdays hash looking for the value or build a hash that has the the
keys turned around(ie, the SAT is the key and 6 is the value.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449           FAX
http://fedex.com/us 

**********************************************************************
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**********************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to