summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-01-31 20:15:34 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-01-31 20:15:34 -0500
commita58fc188f9cd24bdb290c6d9d9e325a09554e572 (patch)
tree39ef582182929db3fbe487841b1f6c8dd1c732e9
parent34976184a55c2548a71fa99f59467abd58725211 (diff)
downloadgames-word-a58fc188f9cd24bdb290c6d9d9e325a09554e572.tar.gz
games-word-a58fc188f9cd24bdb290c6d9d9e325a09554e572.zip
add words_like to search the word list for words matching a given regex
-rw-r--r--lib/Games/Word/Wordlist.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Games/Word/Wordlist.pm b/lib/Games/Word/Wordlist.pm
index f7f9716..0ae24a9 100644
--- a/lib/Games/Word/Wordlist.pm
+++ b/lib/Games/Word/Wordlist.pm
@@ -114,6 +114,14 @@ sub anagrams {
return uniq grep { $self->is_word($_) } all_permutations($word);
}
+sub words_like {
+ my $self = shift;
+ my $re = shift;
+ my @words = ();
+ $self->_each_word(sub { push @words, $_[0] if $_[0] =~ $re });
+ return @words;
+}
+
=head1 NAME
Games::Word::Wordlist - ???