| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::perlfind; | 
| 2 | 2 |  |  | 2 |  | 69141 | use 5.008; | 
|  | 2 |  |  |  |  | 9 |  | 
|  | 2 |  |  |  |  | 87 |  | 
| 3 | 2 |  |  | 2 |  | 12 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 63 |  | 
| 4 | 2 |  |  | 2 |  | 11 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 5 | 2 |  |  | 2 |  | 1865 | use Class::Trigger; | 
|  | 2 |  |  |  |  | 2868 |  | 
|  | 2 |  |  |  |  | 13 |  | 
| 6 | 2 |  |  | 2 |  | 1841 | use Module::Pluggable require => 1; | 
|  | 2 |  |  |  |  | 40033 |  | 
|  | 2 |  |  |  |  | 15 |  | 
| 7 |  |  |  |  |  |  | __PACKAGE__->plugins;    # 'require' them | 
| 8 | 2 |  |  | 2 |  | 5343 | use parent qw(Pod::Cpandoc); | 
|  | 2 |  |  |  |  | 994 |  | 
|  | 2 |  |  |  |  | 92 |  | 
| 9 |  |  |  |  |  |  | our $VERSION = '2.05'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | # separate function so it's testable | 
| 12 |  |  |  |  |  |  | sub find_matches { | 
| 13 | 24 |  |  | 24 | 1 | 106556 | my $word = shift; | 
| 14 | 24 |  |  |  |  | 47 | my @matches; | 
| 15 | 24 |  |  |  |  | 138 | __PACKAGE__->call_trigger('matches.add', \$word, \@matches); | 
| 16 | 24 |  |  |  |  | 423 | return ($word, @matches); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub grand_search_init { | 
| 20 | 0 |  |  | 0 | 0 |  | my ($self, $pages, @found) = @_; | 
| 21 | 0 |  |  |  |  |  | my (@new_pages, $done_opt_f, $done_opt_v); | 
| 22 | 0 |  |  |  |  |  | for my $page (@$pages) { | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | # $page is a search term, see Pod::Perldoc | 
| 25 | 0 |  |  |  |  |  | my @matches; | 
| 26 | 0 |  |  |  |  |  | ($page, @matches) = find_matches($page); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # If perlfunc or perlvar are indicated, set options as though | 
| 29 |  |  |  |  |  |  | # -f or -v were given, respectively, so Pod::Perldoc will only | 
| 30 |  |  |  |  |  |  | # show the relevant part of that document. | 
| 31 | 0 | 0 |  |  |  |  | if (grep { $_ eq 'perlfunc' } @matches) { | 
|  | 0 |  |  |  |  |  |  | 
| 32 | 0 | 0 |  |  |  |  | $self->opt_f_with($page) unless $done_opt_v++; | 
| 33 |  |  |  |  |  |  | } | 
| 34 | 0 | 0 |  |  |  |  | if (grep { $_ eq 'perlvar' } @matches) { | 
|  | 0 |  |  |  |  |  |  | 
| 35 | 0 | 0 |  |  |  |  | $self->opt_v_with($page) unless $done_opt_f++; | 
| 36 |  |  |  |  |  |  | } | 
| 37 | 0 | 0 |  |  |  |  | if (@matches) { | 
| 38 | 0 |  |  |  |  |  | push @new_pages, @matches; | 
| 39 |  |  |  |  |  |  | } else { | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | # pass through; maybe someone higher up knows what to do | 
| 42 |  |  |  |  |  |  | # with it | 
| 43 | 0 |  |  |  |  |  | push @new_pages, $page; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  | } | 
| 46 | 0 |  |  |  |  |  | $self->SUPER::grand_search_init(\@new_pages, @found); | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub opt_V { | 
| 50 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 51 | 0 |  |  |  |  |  | print "perlfind v$VERSION, "; | 
| 52 | 0 |  |  |  |  |  | $self->SUPER::opt_V(@_); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | 1; | 
| 56 |  |  |  |  |  |  | __END__ |