if ($var1 && $var2) { #if they are present if ((exists $hash{$var1}) && ($hash{$var1}=$var2) { # if it exists in hash check to see if key has the right value print "Yup, they work" } else { print "Either it didn't exist or crudentials weren't matched"; }