2 # spell.pl: interface to aspell/ispell/spell
3 # Author: Tim Riker <Tim@Rikers.org>
4 # Source: extracted from UserExtra
5 # Licensing: Artistic License (as perl itself)
8 # Copyright (c) 2005 Tim Riker
17 if ( $query =~ m/[^[:alpha:]]/ ) {
18 return ('only one word of alphabetic characters supported');
22 my @binaries = ( '/usr/bin/aspell', '/usr/bin/ispell', '/usr/bin/spell' );
32 return ('no binary found.');
35 if ( !&::validExec($query) ) {
36 return ('argument appears to be fuzzy.');
39 my $reply = "I can't find alternate spellings for '$query'";
41 foreach (`/bin/echo '$query' | $binary -a -S`) {
43 last if !length; # end of query.
45 if (/^\@/) { # intro line.
48 elsif (/^\*/) { # possibly correct.
49 $reply = "'$query' may be spelled correctly";
52 elsif (/^\&/) { # possible correction(s).
53 s/^\& (\S+) \d+ \d+: //;
54 my @array = split(/,? /);
56 $reply = "possible spellings for $query: @array";
60 &::DEBUG("spell: '+' found => '$_'.");
63 elsif (/^# (.*?) 0$/) {
69 &::DEBUG("spell: unknown: '$_'.");
77 &::performStrictReply( &spell(@_) );
83 # vim:ts=4:sw=4:expandtab:tw=80