http://www.perlmonks.org?node_id=552350

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello!
I have an array which I read each element at a time.
Then I use the array's element as a key for a hash I have created.
If the value of the hash for the given key is correct, I stop reading the array, using 'last'.
If the value is wrong, I keep reading, using 'next'.
What I want to ask is how and where shall I place an error message that will say for example "We read the entire loop and found no matches" ? I guess I must put it somewhere after the next statements?
Imagine that I have something similar to :
foreach $a(@array) { if ($hash{$a}="correct_value") {print "Success"; last;} else {next;} }
Any hints? Thank you in advance!