From 275f0479a6c57f9d58642241016121958b96e6a1 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Sat, 2 Feb 2008 20:31:13 -0500 Subject: make each_word public --- lib/Games/Word/Wordlist.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Games/Word/Wordlist.pm b/lib/Games/Word/Wordlist.pm index 5471d3e..096166a 100644 --- a/lib/Games/Word/Wordlist.pm +++ b/lib/Games/Word/Wordlist.pm @@ -263,7 +263,14 @@ sub _each_word_nocache { return; } -sub _each_word { +=item each_word CODE + +Call CODE for each word in the word list. The current word will be passed into +CODE as its only argument. + +=cut + +sub each_word { my $self = shift; return $self->_each_word_cache(@_) if $self->{cache}; @@ -281,7 +288,7 @@ sub anagrams { my $word = shift; my @words = (); - $self->_each_word(sub { push @words, $_[0] + $self->each_word(sub { push @words, $_[0] if is_permutation($word, $_[0]) }); return @words; @@ -298,7 +305,7 @@ sub words_like { my $re = shift; my @words = (); - $self->_each_word(sub { push @words, $_[0] if $_[0] =~ $re }); + $self->each_word(sub { push @words, $_[0] if $_[0] =~ $re }); return @words; } @@ -315,7 +322,7 @@ sub subwords_of { my $string = shift; my @words = (); - $self->_each_word(sub { push @words, $_[0] + $self->each_word(sub { push @words, $_[0] if is_subpermutation($_[0], $string)}); return @words; -- cgit v1.2.3-54-g00ecf