- my $retval;
- if ($@ && $@ ne "alarm\n") { # failure.
- $retval = "i could not get info from dict.org";
- } else { # success.
- $socket->autoflush(1); # required.
-
- my $num;
- if ($query =~ s/^(\d+)\s+//) {
- $num = $1;
- }
-
- # body.
- push(@results, &Dict_Wordnet($socket,$query));
- push(@results, &Dict_Foldoc($socket,$query));
- # end.
-
- print $socket "QUIT\n";
- close $socket;
-
- my $total = scalar @results;
-
- if ($total == 0) {
- $num = undef;
- }
-
- if (defined $num and ($num > $total or $num < 1)) {
- &::msg($::who, "error: choice in definition is out of range.");
- return;
- }
-
- # parse the results.
- if ($total > 1) {
- if (defined $num) {
- $retval = sprintf("[%d/%d] %s", $num, $total, $results[$num-1]);
- } else {
- # suggested by larne and others.
- my $prefix = "Dictionary '$query' ";
- $retval = &::formListReply(1, $prefix, @results);
- }
- } elsif ($total == 1) {
- $retval = "Dictionary '$query' ".$results[0];
- } else {
- $retval = "could not find definition for \002$query\002";
- }
+ if ($@) {
+
+ # failure.
+ $retval = "i could not get info from $server '$@'";
+ }
+ else { # success.
+ $socket->autoflush(1); # required.
+
+ my $num;
+ if ( $query =~ s/^(\d+)\s+// ) {
+ $num = $1;
+ }
+ my $dict = '*';
+ if ( $query =~ s/\/(\S+)$// ) {
+ $dict = $1;
+ }
+
+ # body.
+ push( @results, &Define( $socket, $query, $dict ) );
+
+ #push(@results, &Define($socket,$query,'foldoc'));
+ #push(@results, &Define($socket,$query,'web1913'));
+ # end.
+
+ print $socket "QUIT\n";
+ close $socket;
+
+ my $count = 0;
+ foreach (@results) {
+ $count++;
+ &::DEBUG("$count: $_");
+ }
+ my $total = scalar @results;
+
+ if ( $total == 0 ) {
+ $num = undef;
+ }
+
+ if ( defined $num and ( $num > $total or $num < 1 ) ) {
+ &::msg( $::who, "error: choice in definition is out of range." );
+ return;
+ }
+
+ # parse the results.
+ if ( $total > 1 ) {
+ if ( defined $num ) {
+ $retval =
+ sprintf( "[%d/%d] %s", $num, $total, $results[ $num - 1 ] );
+ }
+ else {
+
+ # suggested by larne and others.
+ my $prefix = "Dictionary '$query' ";
+ $retval = &::formListReply( 1, $prefix, @results );
+ }
+ }
+ elsif ( $total == 1 ) {
+ $retval = "Dictionary '$query' " . $results[0];
+ }
+ else {
+ $retval = "could not find definition for \002$query\002";
+ $retval .= " in $dict" if ( $dict ne '*' );
+ }