in reply to md5_hex gives different values for same string

Try changing the debugging from:
if ($check =~ $cmd) { print $match_1."\n"; print $check."\n\n"; print $match_2."\n"; print $cmd."\n\n"; }
to:
use Data::Dumper; print Dumper([ $match_1, $check, $match_2, $cmd ]) if $check eq $cmd;
Obviously $check isn't just 'jonsmith' and has additional characters from the word-list file in it. Hopefully this will show them. You could also try (on *nix):
grep jonsmith mil-dic.txt | cat -veT