Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
PerlMonks cli lookup

by diotalevi (Canon)
on Dec 11, 2004 at 06:54 UTC ( #414072=sourcecode: print w/replies, xml ) Need Help??
Category: Text Processing
Author/Contact Info
Description: Convenient access to from emacs, your shell, and if you like, other programs.
Use strict;
use warnings;
use Net::Dict;
use vars qw( $DICT $DICT_HOST %DICT_PARAMS );

$DICT_HOST = '';

main( @ARGV );

sub main {
    initialize( @_ );

    for my $word ( @_ ) {
    my $definitions = $DICT->define( $word );
    for my $definition ( @$definitions ) {
        print dictionary_name( $definition->[0] )
        . "\n$definition->[1]\n";


sub initialize {
    $DICT = Net::Dict->new( $DICT_HOST,
                %DICT_PARAMS );

    $| = 1;


    my %dicts;
    sub dictionary_name {
    my $dict = shift;
    $dicts{$dict} ||= $DICT->dbTitle( $dict );



=head1 NAME

dict - a simple client for


 dict insufflation

 (define-word "insufflation")

 C-x d


Emacs is a great place to bind all sorts things together and this is
no exception. Add this to your .emacs file to create the function
DEFINE-WORD. If you don't give it a word then it will attempt to
define whatever word is currently under your point.

 (defun define-word (input-word)
   "Define a word using"
   (interactive "MWord to define: ")
   (let ((buf (generate-new-buffer "*dict*"))
         (word (if (> (length input-word) 0)
     (shell-command (concat "~/bin/dict " word) buf)

The following command binds C-x d to the function.

 (global-set-key "\C-xd" 'define-word)

Replies are listed 'Best First'.
Re: cli lookup
by belg4mit (Prior) on Dec 12, 2004 at 23:25 UTC
    Question, why on earth would you do this instead of using the dict protocol? Say with Net::Dict?

    I'm not belgian but I play one on TV.

      When I asked people if they knew of a command line client, no one mentioned that Net::Dict existed. Here's a copy of the original source.

        Well a CLI is a horse of a different color altogether. The reference server implementation comes with a good client. From the links section off the main page

        I'm not belgian but I play one on TV.

Re: cli lookup
by tmoertel (Chaplain) on Dec 13, 2004 at 02:58 UTC
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://414072]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-06-01 23:57 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (12 votes). Check out past polls.