in reply to error message in the end of the array looping?

If all you want to do is check if there was atleast one match in the hash value, then you can do as follows...
if ($hash{$a} = "correct_value") { print "Success"; $flag = 1; last; }
At the end of "for" loop, check if $flag==1. If not, you have an error.