in reply to Hash search yields unexpected results

Your issue is not entirely clear to me -- can you clearly state what your expected output is? It seems like it's operating reasonably to me.

As a side note, you iterate over your hash values in checkControlMap. To quote our illustrious figurehead,

Doing linear scans over an associative array is like trying to club someone to death with a loaded Uzi.
-- TimToady
That could be written as

sub checkControlMap { my $check = $_[0]; print "Look for control [$check] - "; my $process = $process_control{$check}; if (not defined $process) { print "WARNING [$check] was not found. - "; $process = 1; } return $process; }
with no change to functional behavior.

Update: Actually, it does cause a change in functional behavior, as mortiz points out below. So use this.

Replies are listed 'Best First'.
Re^2: Hash search yields unexpected results
by moritz (Cardinal) on Feb 13, 2012 at 19:54 UTC

    The iteration over a hash with each is not only inefficient, but also wrong. The reason is that the iterations aren't completed, so the next time the while-loop is entered, the the iteration continues where it left off before.

    That's because the state of the each-iterator is not tied to a lexical scope, but rather to the hash itself.