my %dict = map {split /\s/,$_,2} <$d>; close $d; while (defined (my $line=<$w>)){ for (split /\s/,$line){ if (my $meaning = $dict{$_}){ print "$_: $meaning\n"; next; } print "$_ is not in the dictionary\n"; } } #### 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"; } }