#!/usr/bin/perl use strict; $|++; use Lingua::Ispell qw(:all); use CGI qw(standard); # override the default path - Your Mileage May Vary $Lingua::Ispell::path = '/usr/bin/ispell'; my $cgi = new CGI; print $cgi->header; if (my $query = $cgi->param('query')) { &print_form; &print_corrections($query); } else { &print_form; } #thanks to Randall for this slick dereferencing trick sub print_form { print <<_FORM_;
Enter Text To Spell Check: @{[$cgi->textfield('query')]} @{[$cgi->submit('Go')]} @{[$cgi->endform]}
";
for my $result (spellcheck($query)) {
my $term = "$result->{'term'}";
if ($result->{'type'} eq 'miss') {
print "'$term' was not found in the dictionary,
\n";
print "Near misses: ";
print join(',', @{$result->{'misses'}}), "
\n"; } elsif ($result->{'type'} eq 'none') { print "No match for term '$term'.
\n"; } } }