Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm trying to finish a simple script that first builds a key/value hash. I will then query the hash to test the equality of a value with a new given value.
I don't understand why this doesn't work:
if(($hash{$key}) eq $value)
Any ideas?
while ($line = <F>) { chomp($line); ($value, $key) = split(/=/, $line); if(exists $hash{$key}) { if(($hash{$key}) eq $value) { print "YES: ", ($hash{$key}) ," == $value\n"; } else { print "NOT: ", ($hash{$key}) ," != $value\n"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting the Value of a single hash key
by pzbagel (Chaplain) on May 06, 2003 at 20:21 UTC | |
(jeffa) Re: Getting the Value of a single hash key
by jeffa (Bishop) on May 06, 2003 at 19:35 UTC | |
by Anonymous Monk on May 06, 2003 at 19:42 UTC | |
by ChrisS (Monk) on May 06, 2003 at 19:58 UTC | |
Re: Getting the Value of a single hash key
by pzbagel (Chaplain) on May 06, 2003 at 19:57 UTC | |
by dogz (Initiate) on May 06, 2003 at 20:05 UTC | |
by dogz (Initiate) on May 06, 2003 at 20:19 UTC |
Back to
Seekers of Perl Wisdom