bin/pmpath

filter: Statementstmt 78.5% 22 / 28 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 77.1% 27 / 35 CC 1 SCAR 0.0
CC
1
Cov
75%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« bin/faqpods ↑ Summary bin/pmls »
1 #!/usr/bin/env perl
2 # pmpath -- show path to a perl module
3  
4 # ------ pragmas
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 our $VERSION = '2.0.0';
9  
10 # ------ define variables
11 5 my $errors = 0; # error count
12 5 my $fullpath = undef; # full path
13 5 my $module = undef; # module name
14 5 my $shortpath = undef; # short path
15  
16 5 ▶BEGIN { $^W = 1 }
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 $errors = 0;
19  
20 5 for $module (@ARGV) {
21 5 eval "local \$^W = 0; require $module";
22 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 5 5
23 0 $@ =~ s/at \(eval.*$//;
24 0 warn "$0: $@";
25 0 $errors++;
26 0 next;
27 }
28 5 for ($shortpath = $module) {
29 5 s{::}{/}g;
30 5 s/$/.pm/;
31 }
32 # print "$module is in " if @ARGV > 1;
33 5 ▶ if (defined($fullpath = $INC{$shortpath})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($fullpath = $INC{$shortpath})) { } 5 0 5
34 5 print "$fullpath\n";
35 }
36 else {
37 0 $errors++;
38 0 warn "$0: path unavailable in %INC\n";
39 }
40 }
41  
42 5 exit ($errors != 0);
43  
44 __END__
« bin/faqpods ↑ Summary bin/pmls »