my %dict = map split( ' ', $_, 2 ), <$d>; close $d; while ( <$w> ) { for my $word ( split ) { if ( exists $dict{ $word } ) { print "$word: $dict{ $word }"; next; } print "$word is not in the dictionary\n"; } }