in reply to Comparing hash keys and values with Regular Expressions

You've received some excellent advice about your code. At the risk of confusing the issue (and I apologize in advance if it does), consider the following:

use Modern::Perl; use open ':utf8'; use autodie; my (%nonmatchhash, @hashvalues); open my $NONMATCHINPUT, '<', 'OutputNonMatchedWords.txt'; do { /(.*)\t(.*)/; $nonmatchhash{$1} = $2; push @hashvalues, $2 } for <$NONMATCHINPUT>; close $NONMATCHINPUT; while ( my ( $key, $value ) = each %nonmatchhash ) { given ($key) { when (/\A$value\z/) { say "key '$key' eq value '$value'"; } when (/(.*)(agtig)(e|er|ste)?$/) { say "$key\t$_" for grep /(.*)(achtig)(e|er|ste)?$/, @hashvalues; } default { say "No match for key '$key'"; } } }

From what I could gather from your code, it looks like you're taking an action after testing for three conditions, viz., 1) key/value equality, 2) matching a key, then a value under that key, and 3) no match. The script above handles these three cases, and may assist your coding decisions.

Hope this helps!