in reply to hash confusion

if (exists($hash{$1}) and $hash{$1} eq $2) { ... }

Basically, you make sure that $1 is in the hash, and that its associated value is the same as $2