On 5 Jul 2006 at 10:56, Mumia W. wrote:
> Beginner wrote:
> > Hi,
> >
> > I am being a bit lazy here. I already had this hash defined (cut & pasted
> > from another file) and
> > didn't want to re-type it.
> >
> > my %char = (
> > 65 => 'a',
> > 66 => 'b',
> > 67 => 'c',
> > 68
Beginner wrote:
>
> I am being a bit lazy here. I already had this hash defined (cut &
> pasted from another file) and didn't want to re-type it.
>
> my %char = (
> 65 => 'a',
> 66 => 'b',
> 67 => 'c',
> 68 => 'd',
> 69 => 'e',
> 70 => 'f',
> 71 => 'g',
> 72 => 'h',
> 73 => 'i',
Beginner wrote:
Hi,
I am being a bit lazy here. I already had this hash defined (cut & pasted from another file) and
didn't want to re-type it.
my %char = (
65 => 'a',
66 => 'b',
67 => 'c',
68 => 'd',
[...]
But now I need to find the key given the value. EG: Wh
"Beginner" schreef:
> I am being a bit lazy here. I already had this hash defined (cut &
> pasted from another file) and didn't want to re-type it.
>
> my %char = (
> 65 => 'a',
> ...
> );
>
>
> But now I need to find the key given the value. EG: What is the ASCII
> value for 'a'?
>
> Am I being d
Beginner wrote:
> But now I need to find the key given the value. EG: What is the ASCII value
> for 'a'?
>
%char = reverse %char;
Note that this trick only works if the values of the original hash are
unique.
--
__END__
Just my 0.0002 million dollars worth,
--- Shawn
"For the things
You'd be better off making a second hash:
my %reverse_char;
while(my($key,$value) = each %char){
$reverse_char{$value} = $key;
}
print $reverse_char{a};
-Original Message-
From: Beginner [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 05, 2006 8:48 AM
To: beginners@perl.org
Subj