Me again...
I have a hash and I'm trying to access the keys using a specific value. Is it possible??
The simplest example I can give would be the following
What I am trying to do is simple in my head, but maybe I'm not thinking "the perl way"? Or is there something I'm doing wrong?
Thanks in advance,
Anthony
I have a hash and I'm trying to access the keys using a specific value. Is it possible??
The simplest example I can give would be the following
Code:
#!/usr/bin/perl -w
%data = (
'Jan' => 31,
'Feb' => 28,
'Mar' => 31,
'Apr' => 30);
$val = "31";
foreach $month (keys %data)
{
if ($val = $data{$val})
{
print "$month\n";
}
}
What I am trying to do is simple in my head, but maybe I'm not thinking "the perl way"? Or is there something I'm doing wrong?
Thanks in advance,
Anthony