jshock wrote:
>
> For example:
>
> my %weekdays = (
> 0 => "SUN",
> 1 => "MON",
> 2 => "TUE",
> 3 => "WED",
> 4 => "THU",
> 5 => "FRI",
> 6 => "SAT",
> );
All those double quotes without any interpolation?
my %weekdays;
@weekdays{0..6}= qw/SUN MON TUE WED THU FRI 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"
If you are certain that your values are unique then you can create an inverse
hash:
my %weeknames = reverse %weekdays;
print $weeknames{TUE};
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/