From a58fc188f9cd24bdb290c6d9d9e325a09554e572 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Thu, 31 Jan 2008 20:15:34 -0500 Subject: add words_like to search the word list for words matching a given regex --- lib/Games/Word/Wordlist.pm | 8 ++++++++ 1 file changed, 8 insertions(+) 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 - ??? -- cgit v1.2.3-54-g00ecf