File Coverage

blib/lib/App/perlfind/Plugin/Functions.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


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