use CGI qw/:all/; use vars qw($DICT_FILE %DICT $CSS); $CSS = ".highlight { font-weight: bold; color: #F00; } * { font-size: medium; font-family: sans-serif; }"; $DICT_FILE = "/usr/dict/words2"; open DICT, "<", $DICT_FILE or die "Couldn't open $DICT_FILE: $!"; while ( my $word = ) { chomp $word; $DICT{lc $word} = undef; } close DICT or warn "Couldn't close $DICT_FILE: $!"; # Response header to send back to the requesting web page print header(), start_html( -title => 'Spell Check API Example', -style => $CSS, ), h3("The following " . span( { class => 'highlight' }, 'highlighted' ) . " words are not found in the English dictionary."), br(), start_table( { border => 1 } ); for my $param ( sort param() ) { my @words = split ' ', param($param); for my $word ( @words ) { if ( not exists $DICT{lc $word} and not exists $KNOWN_MISPELLINGS{lc $word} ) { $word = span( { class => 'highlight' }, $word ); } } print Tr( td( b( $param ), ' ', join(' ', @words) ) ); } print end_table(), br(), br(), span( { -font_size => small }, 'Spell Check API Example' ), end_html();