| IRC-Bot-Hangman documentation | Contained in the IRC-Bot-Hangman distribution. |
IRC::Bot::Hangman::WordList - Word list plugin engine
use IRC::Bot::Hangman::WordList; $words = IRC::Bot::Hangman::WordList->load( 'too_easy' ); print $words->[3];
This module loads the word list plugins and provide a list based on a name
Returns a word list loaded from a specific plugin
Loads the word list
Pierre Denis <pierre@itrelease.net>
http://www.itrelease.net/
Copyright 2005 IT Release Ltd - All Rights Reserved.
This module is released under the same license as Perl itself.
| IRC-Bot-Hangman documentation | Contained in the IRC-Bot-Hangman distribution. |
package IRC::Bot::Hangman::WordList; use warnings::register; use strict; use Carp qw( carp croak ); use Module::Find qw( useall ); our %WORDLISTS = map { $_->name => $_ } useall( __PACKAGE__ );
sub load { my $class = shift; my $name = shift; my $module = $WORDLISTS{$name}; unless ($module) { carp "$name is not a registered word list, try " . join(' or ', keys %WORDLISTS); return; } $class->word_list( $module ); }
sub word_list { my $self = shift; my $module = shift; my $fh = "${module}::DATA"; my @words; while (<$fh>) { chomp; push @words, $_ if $_; } \@words; } 1;