- my $query = shift;
- if ($query =~ m/[^[:alpha:]]/) {
- return('only one word of alphabetic characters supported');
- }
-
- my $binary;
- my @binaries = (
- '/usr/bin/aspell',
- '/usr/bin/ispell',
- '/usr/bin/spell'
- );
-
- foreach (@binaries) {
- if (-x $_) {
- $binary=$_;
- last;
- }
- }
-
- if (!$binary) {
- return('no binary found.');
- }
-
- if (!&::validExec($query)) {
- return('argument appears to be fuzzy.');
- }
-
- my $reply = "I can't find alternate spellings for '$query'";
-
- foreach (`/bin/echo '$query' | $binary -a -S`) {
- chop;
- last if !length; # end of query.
-
- if (/^\@/) { # intro line.
- next;
- } elsif (/^\*/) { # possibly correct.
- $reply = "'$query' may be spelled correctly";
- last;
- } elsif (/^\&/) { # possible correction(s).
- s/^\& (\S+) \d+ \d+: //;
- my @array = split(/,? /);
-
- $reply = "possible spellings for $query: @array";
- last;
- } elsif (/^\+/) {
- &::DEBUG("spell: '+' found => '$_'.");
- last;
- } elsif (/^# (.*?) 0$/) {
- # none found.
- last;
- } else {
- &::DEBUG("spell: unknown: '$_'.");
- }
- }
-
- return($reply);
+ my $query = shift;
+ if ( $query =~ m/[^[:alpha:]]/ ) {
+ return ('only one word of alphabetic characters supported');
+ }
+
+ my $binary;
+ my @binaries = ( '/usr/bin/aspell', '/usr/bin/ispell', '/usr/bin/spell' );
+
+ foreach (@binaries) {
+ if ( -x $_ ) {
+ $binary = $_;
+ last;
+ }
+ }
+
+ if ( !$binary ) {
+ return ('no binary found.');
+ }
+
+ if ( !&::validExec($query) ) {
+ return ('argument appears to be fuzzy.');
+ }
+
+ my $reply = "I can't find alternate spellings for '$query'";
+
+ foreach (`/bin/echo '$query' | $binary -a -S`) {
+ chop;
+ last if !length; # end of query.
+
+ if (/^\@/) { # intro line.
+ next;
+ }
+ elsif (/^\*/) { # possibly correct.
+ $reply = "'$query' may be spelled correctly";
+ last;
+ }
+ elsif (/^\&/) { # possible correction(s).
+ s/^\& (\S+) \d+ \d+: //;
+ my @array = split(/,? /);
+
+ $reply = "possible spellings for $query: @array";
+ last;
+ }
+ elsif (/^\+/) {
+ &::DEBUG("spell: '+' found => '$_'.");
+ last;
+ }
+ elsif (/^# (.*?) 0$/) {
+
+ # none found.
+ last;
+ }
+ else {
+ &::DEBUG("spell: unknown: '$_'.");
+ }
+ }
+
+ return ($reply);