NAME
WWW::LEO - Perl interface to the English-German online dictionary at http://dict.leo.org
SYNOPSIS
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;
}
DESCRIPTION
This module provides an interface to the English-German online dictionary located at http://dict.leo.org.
METHODS
new
-
This constructs a new
WWW::LEO
object. You can pass a hashref with configuration info to the constructor. Currently recognized key words are: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. reset
-
Resets the
WWW::LEO
object to the state as if no query had been made. Returns the resettedWWW::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. agent
-
Returns the
LWP::UserAgent
object thatWWW::LEO
uses to query the dictionary. request
-
Returns the
HTTP::Request
object thatWWW::LEO
passes toLWP::UserAgent
when quering the dictionary. response
-
Returns the
HTTP::Response
object that results from the query to the dictionary. 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.
Returns
undef
if no query has been made. maxlen_en
-
This is a convenience method: returns the longest string of the German results.
Returns
undef
if no query has been made. 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
-
Convenience method: Returns an array reference containing the English results.
EXPORT
None, as this is an object-oriented module.
SEE ALSO
the http://dict.leo.org homepage
the sample clients included with this package:
LEO clients written in Perl (not using this module):
http://scripts.irssi.de/html/leodict.pl.html (this is a plugin script for the
irssi
IRC client, see http://www.irssi.org)
KNOWN BUGS AND OTHER ISSUES
The parsing scheme used to extract the results could probably be improved to be more robust.
TODO
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.
SUPPORT
Please contact the current maintainer of this module to report any bugs or suggest changes to this module:
Jörg Ziefle <ziefle@cpan.org>
AUTHOR
Jörg Ziefle <ziefle@cpan.org>
COPYRIGHT AND LICENSE
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.