I have this assignment we have to create a simple spell checker we have 1 file called words.txt that contains like 4,000 words and than we have another file called text.txt that contains just random words some are mispelled this is my program.
open INFILE, "words.txt" or die "can't open file $!";
while ($word = <INFILE>)
{
chomp($word);
$dict{$word}=1;
}
while ($word = <>)
{
chomp($word);
@words=split//,$word;
if(!exists $dict{$word})
{
print "$word is mispelled\n";
}
}
The problem that I am having is that my text.txt file contains something like this.
Ex
more cat lose
pat red persan
when I run the program it prints them together like
more cat lose is mispelled instead of breaking them apart.
Thanks, any help or advice would be useful =)