use strict; use warnings; my %dict; open my $infile, '<', 'words.txt' or die "can't open file $!"; while ( my $word = <$infile> ) { chomp $word; $dict{$word} = 1; } close $infile; while ( my $line = <> ) { my @words = split /\s+/, $line; for my $word (@words) { if ( !exists $dict{$word} ) { print "$word is mispelled\n"; } } }