WWW::LEO - Perl interface to the English-German online dictionary at http://dict.leo.org
use WWW::LEO; use Data::Dumper; my $leo = WWW::LEO->new; $leo->query("@ARGV"); if ($leo->num_results) { my $i; foreach my $resultpair (@{$leo->en_de}) { printf "%3d: %-40s %s\n", ++$i, @$resultpair; } } else { print "Sorry, your query for '%s'gave no results.\n", $leo->query; }
This module provides an interface to the English-German online dictionary located at http://dict.leo.org.
new
This constructs a new WWW::LEO object. You can pass a hashref with configuration info to the constructor. Currently recognized key words are:
WWW::LEO
agent
sets the user agent string that is used to identify the module
query
If a scalar is supplied, queries the dictionary for the string contained within. Returns the number of results.
If no argument is given, returns the query string of the last query. Returns undef if no query has been made yet with this object.
undef
reset
Resets the WWW::LEO object to the state as if no query had been made. Returns the resetted WWW::LEO object.
This method shouldn't be used in normal cases. It's there to provide the possibility of explicitely cleaning up the WWW::LEO object.
Returns the LWP::UserAgent object that WWW::LEO uses to query the dictionary.
LWP::UserAgent
request
Returns the HTTP::Request object that WWW::LEO passes to LWP::UserAgent when quering the dictionary.
HTTP::Request
response
Returns the HTTP::Response object that results from the query to the dictionary.
HTTP::Response
num_results
Returns the number of results of the last query.
Returns undef if no query has been made.
maxlen_de
This is a convenience method: returns the longest string in of the English results.
maxlen_en
This is a convenience method: returns the longest string of the German results.
en_de
Returns a reference to an array whose elements are references to arrays containing the English and German result pairs in elements 0 and 1, respectively.
en
Convenience method: Returns an array reference containing the English results.
de
None, as this is an object-oriented module.
the http://dict.leo.org homepage
the sample clients included with this package:
for a simple example
for a fully-fledged program
LEO clients written in Perl (not using this module):
ftp://ftp.daemon.de/scip/Scripts/leo
http://cgi.xwolf.de/perl/leo.txt
http://scripts.irssi.de/html/leodict.pl.html (this is a plugin script for the irssi IRC client, see http://www.irssi.org)
irssi
The parsing scheme used to extract the results could probably be improved to be more robust.
implement more robust parsing scheme
provide more flexibility for the user (constructor options, ...)
implement support for headlines ("Direct Matches (+ Prepositions)", "Composed Entries", ...) and other LEO options (see the web page)
Also see the TODO file contained in the module distribution.
Please contact the current maintainer of this module to report any bugs or suggest changes to this module:
Jörg Ziefle <ziefle@cpan.org>
Copyright 2002 by Jörg Ziefle
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WWW::LEO, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::LEO
CPAN shell
perl -MCPAN -e shell install WWW::LEO
For more information on module installation, please visit the detailed CPAN module installation guide.