@dictionary = ("doable", "docile", "doctor"); $line = ; chomp($line); foreach $word (@dictionary){ if($line =~ /^$word$/){ print "The word $line appears in the dictionary.\n"; exit; } else{ for($i = 0; $i < length($word); $i++){ $pattern = substr($word, 0, $i); $pattern = $pattern . "."; $pattern = $pattern . substr($word, $i + 1, length($word)); if($line =~ /^$pattern$/){ print "The word $line is a misspelt version of $word.\n"; exit; } } } } print "The word $line does not appear in the dictionary.\n";