line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WordListRole::FirstNextResetFromEach; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
479
|
use Role::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires 'each_word'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
8
|
|
|
|
|
|
|
our $DATE = '2021-09-26'; # DATE |
9
|
|
|
|
|
|
|
our $DIST = 'WordList'; # DIST |
10
|
|
|
|
|
|
|
our $VERSION = '0.7.11'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub first_word { |
13
|
2
|
|
|
2
|
1
|
4983
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
6
|
$self->reset_iterator; |
16
|
2
|
|
|
|
|
4
|
$self->next_word; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub next_word { |
20
|
10
|
|
|
10
|
1
|
20
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
10
|
100
|
|
|
|
28
|
unless ($self->{_all_words}) { |
23
|
2
|
|
|
|
|
3
|
my @wordlist; |
24
|
2
|
|
|
4
|
|
10
|
$self->each_word(sub { push @wordlist, $_[0] }); |
|
4
|
|
|
|
|
9
|
|
25
|
2
|
|
|
|
|
9
|
$self->{_all_words} = \@wordlist; |
26
|
|
|
|
|
|
|
} |
27
|
10
|
50
|
|
|
|
23
|
$self->{_iterator_idx} = 0 unless defined $self->{_iterator_idx}; |
28
|
|
|
|
|
|
|
|
29
|
10
|
100
|
|
|
|
44
|
return undef if $self->{_iterator_idx} > $#{ $self->{_all_words} }; ## no critic: Subroutines::ProhibitExplicitReturnUndef |
|
10
|
|
|
|
|
43
|
|
30
|
8
|
|
|
|
|
78
|
$self->{_all_words}[ $self->{_iterator_idx}++ ]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub reset_iterator { |
34
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
9
|
$self->{_iterator_idx} = 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
# ABSTRACT: Provide first_word(), next_word(), reset_iterator(); relies on each_word() |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |