The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Scrabble::Dict - look up words in the official Scrabble dictionary

SYNOPSIS

  # 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;
    }
  }

DESCRIPTION

Scrabble::Dict is a screen-scraper interface to the Official Scrabble Player's Dictionary (OSPD) available online at http://www.hasbro.com/scrabble.

METHODS

$dict = Scrabble::Dict->new(%options, %lwp_options);

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.

$dict->define($word)

Lookup the definition for a word. If no match is found, return the value of the 'undefined_as' option.

$dict->scrape_definition($html, $word)

Internal: finds the needle in the haystack. You could subclass and override if the page layout changes.

FUNCTIONS

scrabble_define($word, %options, %lwp_options)

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.

AUTHOR

Alan Grow <agrow+nospam@thegotonerd.com>

COPYRIGHT AND LICENSE

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.