File Coverage

blib/lib/App/perlfind/Plugin/UseModule.pm
Criterion Covered Total %
statement 31 57 54.3
branch n/a
condition n/a
subroutine 19 19 100.0
pod n/a
total 50 76 65.7


line stmt bran cond sub pod time code
1             package App::perlfind::Plugin::UseModule;
2 2     2   4085 use 5.008;
  2         9  
  2         175  
3 2     2   13 use strict;
  2         4  
  2         78  
4 2     2   16 use warnings;
  2         4  
  2         91  
5 2     2   12 use App::perlfind;
  2         3  
  2         1323  
6             our $VERSION = '2.05';
7             App::perlfind->add_trigger(
8             'matches.add' => sub {
9             my ($class, $word, $matches) = @_;
10             # does it look like a package name?
11             return unless $$word =~ /^\w+(::\w+)*$/;
12             my $try_module = sub {
13             my $module = shift;
14 1     1   806 eval "use $module;";
  0     1   0  
  0     1   0  
  1     1   7  
  1     1   2  
  1     1   24  
  1     1   618  
  0     1   0  
  0     1   0  
  1     1   391  
  0     1   0  
  0     1   0  
  1     1   6  
  1     1   3  
  1     1   13  
  1         496  
  0         0  
  0         0  
  1         434  
  0         0  
  0         0  
  1         773  
  0         0  
  0         0  
  1         454  
  0         0  
  0         0  
  1         559  
  0         0  
  0         0  
  1         454  
  0         0  
  0         0  
  1         522  
  0         0  
  0         0  
  1         456  
  0         0  
  0         0  
  1         727  
  0         0  
  0         0  
  1         452  
  0            
  0            
15             return 0 if $@;
16             push @$matches, $module;
17             return 1;
18             };
19              
20             # try it as a module
21             return if $try_module->($$word);
22              
23             if ($$word =~ /::[A-Z]\w*$/) {
24             push @$matches, $$word;
25             } elsif ($$word =~ s/::\w+$//) {
26             $try_module->($$word);
27             }
28             }
29             );
30             1;
31             __END__