bin/pman

filter: Statementstmt 96.9% 32 / 33 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 86.5% 45 / 52 CC 2 SCAR 2.8
CC
2
Cov
87%
BEGIN
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« bin/plxload ↑ Summary /usr/local/bin/pod2text »
1 #!/usr/bin/env perl
2 # pman -- show a module's man page
3  
4 # ------ pragmas
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use pmtools;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '2.1.0';
10  
11 # ------ define variables
12 1 my $module; # module name
13 my $pager; # $ENV{PAGER} - pager program
14 1 my $path; # path for pod2text
15  
16 1 ▶BEGIN { $^W = 1 }
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶BEGIN { die "usage: $0 module ...\n" unless @ARGV }
Subroutine BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 0 1 1
18  
19 1 ▶use FindBin qw($Bin);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶unless ($pager = $ENV{PAGER}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pager = $ENV{"PAGER"}) 1 0 1
22 1 require Config;
23 1 ▶ $pager = $Config::Config{"pager"} || "more";
Condition50%1/2
$Config::Config{'pager'} || 'more'
l!l
10
MC/DC0%0/1
$Config::Config{'pager'} || 'more'
$Config::Config{'pager'}
Truth table50%1/2
A
A= $Config::Config{'pager'}
Aresult
11
00
24 }
25  
26 1 for $module (@ARGV) {
27 1 $module =~ s#::#/#gmsx;
28 1 my $found = 0;
29 1 my $iter = pmtools::new_pod_iterator($module);
30  
31 1 ▶ while (my $pod = $iter->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pod = &$iter()) 21 0 21
32 21 ▶ if (-s $pod) {
Branch: 1 branch
BranchTrueFalseTotal
if (-s $pod) 1 20 21
33 1 $path = $pod;
34 1 $found++;
35 1 last;
36 }
37 }
38
39 1 ▶ if (!$found) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 0 1 1
40 0 next;
41 }
42 1 system "$^X -S pod2text $path | $pager";
43 }
44  
45 1 exit(0);
46  
47 __END__
« bin/plxload ↑ Summary /usr/local/bin/pod2text »