File Coverage

blib/lib/App/perlfind/Plugin/Functions.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package App::perlfind::Plugin::Functions;
2 10     10   4148394 use strict;
  10         24  
  10         378  
3 10     10   47 use warnings;
  10         15  
  10         280  
4 10     10   452 use App::perlfind;
  10         12  
  10         73  
5 10     10   5999 use Pod::Functions;
  10         29921  
  10         4607  
6             our $VERSION = '2.07';
7              
8             # Use a look-up hash, so duplicates that appear more than once in
9             # %Kinds are deduped; also add cleaned versions of functions found in
10             # %Kinds. For example, for "qw/STRING/" also add "qw"; for "y///" also
11             # add "y"; for "-X" also add "X".
12              
13             my %is_function;
14             for my $function (map { @$_ } values %Kinds) {
15             $is_function{$function}++;
16             (my $cleaned = $function) =~ s!/STRING/!!;
17             $cleaned =~ s/[^a-z]//g;
18             $is_function{$cleaned}++;
19             }
20             App::perlfind->add_trigger(
21             'matches.add' => sub {
22             my ($class, $word, $matches) = @_;
23             if ($is_function{$$word}) {
24             # Add perlop as well because some thing are found there:
25             # "s", "m", "tr" etc.; see Pod::Perldoc
26              
27             push @$matches, qw(perlfunc perlop);
28             } elsif ($$word =~ /-[rwxoRWXOeszfdlpSbctugkTBMAC]/) {
29             $$word = '-X';
30             push @$matches, qw(perlfunc perlop);
31             } elsif ($$word eq 'PROPAGATE') {
32             $$word = 'die';
33             push @$matches, qw(perlfunc perlop);
34             }
35             }
36             );
37             1;
38             __END__