Scrabble::Dict - look up words in the official Scrabble dictionary
# procedural interface use Scrabble::Dict qw/scrabble_define/; print scrabble_define('quixotry')."\n"; # OO interface use Scrabble::Dict; my $dict = Scrabble::Dict->new(env_proxy => 1); # example: look up all the two letter words for my $c0 ('a' .. 'z') { for my $c1 ('a' .. 'z') { my $def = $dict->define($c0.$c1); print "${c0}${c1} $def\n" if $def; } }
Scrabble::Dict is a screen-scraper interface to the Official Scrabble Player's Dictionary (OSPD) available online at http://www.hasbro.com/scrabble.
Construct a new Scrabble dictionary object. Recognized options are:
host hostname of Scrabble site uri_home path of home page where we get cookies uri_dict path + query of word lookup page undefined_as return this when no definition is found
These default to values which work currently, but may stop working at any given moment--this is screen-scraping after all. Any other key-value options are passed on to the constructor of LWP::UserAgent, giving you some finer-grained control over the connection. Refer to LWP::UserAgent for more.
Before the actual word lookup is performed, cookies must be obtained from the Hasbro home page. The first call to define() on a Scrabble::Dict will take care of this. Subsequent calls on that object will be faster.
Lookup the definition for a word. If no match is found, return the value of the 'undefined_as' option.
Internal: finds the needle in the haystack. You could subclass and override if the page layout changes.
Look up a word using a new Scrabble::Dict object. See new() for a description of available options. Note that the OO interface will be faster for multiple lookups.
Alan Grow <agrow+nospam@thegotonerd.com>
This module is not endorsed by Hasbro Inc. The name Scrabble is a registered trademark of Hasbro Inc.
Copyright (C) 2007 by Alan Grow
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
To install Scrabble::Dict, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Scrabble::Dict
CPAN shell
perl -MCPAN -e shell install Scrabble::Dict
For more information on module installation, please visit the detailed CPAN module installation guide.