Perlinfo/Common.pm

filter: Statementstmt 36.0% 70 / 194 Branchbran 16.4% 22 / 134 Conditioncond 2.9% 3 / 101 MC/DCmcdc 0.0% 0 / 56 Subroutinesub 55.1% 16 / 29 Podpod 0.0% 0 / 25 totaltotal 20.5% 111 / 539 CC 103 SCAR 57.2
CC
103
Cov
22%
check_module_args
600.0
which
552.0
add_link
433.1
CRAP 304.0
↑ Summary Perlinfo/Modules.pm »
1 package HTML::Perlinfo::Common;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 our @ISA = qw(Exporter);
6 5 our @EXPORT = qw(initialize_globals print_table_colspan_header print_table_row print_table_color_start print_table_color_end print_color_box print_table_row_color print_table_start print_table_end print_box_start print_box_end print_hr print_table_header print_section print_license add_link check_path check_args check_module_args perl_version release_date process_args error_msg match_string);
7 5 require Exporter;
8  
9 5 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our %links;
12  
13 5 %links = (
14 'all' => 1,
15 'local' => 0,
16 'docs' => 1,
17 );
18  
19  
20 ##### The following is lifted from File::Which 0.05 by Per Einar Ellefsen.
21 ##### The check_path sub uses the which sub.
22 #############
23 5 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 5 my $Is_VMS = ($^O eq 'VMS');
26 5 my $Is_MacOS = ($^O eq 'MacOS');
27 5 ▶my $Is_DOSish = (($^O eq 'MSWin32') or
Condition33%2/6
$^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'os2'
l!l&&r!l&&!r
005
$^O eq "MSWin32" or $^O eq "dos"
l!l&&r!l&&!r
005
MC/DC0%0/3
$^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'os2'
$^O eq "MSWin32" $^O eq "dos" $^O eq 'os2'
Truth table0%0/4
A or B || C
A= $^O eq "MSWin32"B= $^O eq "dos"C= $^O eq 'os2'
ABCresult
1XX1
01X1
0011
0000
28 ($^O eq 'dos') or
29 ($^O eq 'os2'));
30  
31 # For Win32 systems, stores the extensions used for
32 # executable files
33 # For others, the empty string is used
34 # because 'perl' . '' eq 'perl' => easier
35 5 my @path_ext = ('');
36 5 ▶if ($Is_DOSish) {
Branch: 2 branches
BranchTrueFalseTotal
if ($Is_DOSish) { } 0 5 5
elsif ($Is_VMS) { } 0 5 5
37 0 ▶ if ($ENV{PATHEXT} and $Is_DOSish) { # WinNT. PATHEXT might be set on Cygwin, but not used.
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PATHEXT'} and $Is_DOSish) { } 0 0 0
Condition0%0/3
$ENV{"PATHEXT"} and $Is_DOSish
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"PATHEXT"} and $Is_DOSish
$ENV{"PATHEXT"} $Is_DOSish
Truth table0%0/3
A and B
A= $ENV{"PATHEXT"}B= $Is_DOSish
ABresult
0X0
100
111
38 0 push @path_ext, split ';', $ENV{PATHEXT};
39 }
40 else {
41 0 push @path_ext, qw(.com .exe .bat); # Win9X or other: doesn't have PATHEXT, so needs hardcoded.
42 }
43 }
44 elsif ($Is_VMS) {
45 0 push @path_ext, qw(.exe .com);
46 }
47  
48 sub which {
49 0 ▶ my ($exec) = @_;
Subroutine which: not called CC=23 SCAR=63.1
Pod undocumented
50  
51 0 ▶ return undef unless $exec;
Branch: 1 branch
BranchTrueFalseTotal
unless $exec 0 0 0
52  
53 0 my $all = wantarray;
54 0 my @results = ();
55
56 # check for aliases first
57 0 ▶ if ($Is_VMS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Is_VMS) 0 0 0
58 0 my $symbol = `SHOW SYMBOL $exec`;
59 0 chomp($symbol);
60 0 ▶ if (!$?) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($?) 0 0 0
61 0 ▶ return $symbol unless $all;
Branch: 1 branch
BranchTrueFalseTotal
unless $all 0 0 0
62 0 push @results, $symbol;
63 }
64 }
65 0 ▶ if ($Is_MacOS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Is_MacOS) 0 0 0
66 0 my @aliases = split /\,/, $ENV{Aliases};
67 0 foreach my $alias (@aliases) {
68 # This has not been tested!!
69 # PPT which says MPW-Perl cannot resolve `Alias $alias`,
70 # let's just hope it's fixed
71 0 ▶ if (lc($alias) eq lc($exec)) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $alias eq lc $exec) 0 0 0
72 0 chomp(my $file = `Alias $alias`);
73 0 ▶ last unless $file; # if it failed, just go on the normal way
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
74 0 ▶ return $file unless $all;
Branch: 1 branch
BranchTrueFalseTotal
unless $all 0 0 0
75 0 push @results, $file;
76 # we can stop this loop as if it finds more aliases matching,
77 # it'll just be the same result anyway
78 0 last;
79 }
80 }
81 }
82  
83 0 my @path = File::Spec->path();
84 0 ▶ unshift @path, File::Spec->curdir if $Is_DOSish or $Is_VMS or $Is_MacOS;
Branch: 1 branch
BranchTrueFalseTotal
if $Is_DOSish or $Is_VMS or $Is_MacOS 0 0 0
Condition0%0/6
$Is_DOSish or $Is_VMS or $Is_MacOS
l!l&&r!l&&!r
000
$Is_DOSish or $Is_VMS
l!l&&r!l&&!r
000
MC/DC0%0/3
$Is_DOSish or $Is_VMS or $Is_MacOS
$Is_DOSish $Is_VMS $Is_MacOS
Truth table0%0/4
A or B or C
A= $Is_DOSishB= $Is_VMSC= $Is_MacOS
ABCresult
1XX1
01X1
0011
0000
85  
86 0 for my $base (map { File::Spec->catfile($_, $exec) } @path) {
87 0 for my $ext (@path_ext) {
88 0 my $file = $base.$ext;
89  
90 0 ▶ if ((-x $file or # executable, normal case
Branch: 1 branch
BranchTrueFalseTotal
if (-x $file || ($Is_MacOS || $Is_DOSish && grep({$file =~ /$_$/i;} @path_ext[1 .. $#path_ext])) && -e _ and not -d _) 0 0 0
Condition0%0/15
-x $file || ($Is_MacOS || $Is_DOSish && grep({$file =~ /$_$/i;} @path_ext[1 .. $#path_ext])) && -e _ and not -d _
!ll&&!rl&&r
000
-x $file or $Is_MacOS || $Is_DOSish && grep({$file =~ /$_$/i;} @path_ext[1 .. $#path_ext]) and -e _
l!l&&r!l&&!r
000
$Is_MacOS || $Is_DOSish && grep({$file =~ /$_$/i;} @path_ext[1 .. $#path_ext]) and -e _
!ll&&!rl&&r
000
$Is_MacOS or $Is_DOSish and grep {$file =~ /$_$/i;} @path_ext[1 .. $#path_ext]
l!l&&r!l&&!r
000
$Is_DOSish and grep {$file =~ /$_$/i;} @path_ext[1 .. $#path_ext]
!ll&&!rl&&r
000
MC/DC0%0/6
-x $file || ($Is_MacOS || $Is_DOSish && grep({$file =~ /$_$/i;} @path_ext[1 .. $#path_ext])) && -e _ and not -d _
-x $file $Is_MacOS $Is_DOSish grep {$file =~ /$_$/i;} @path_ext[1 .. $#path_ext] -e _ not -d _
Truth table0%0/10
A or B or C and D and E and not(F)
A= -x $fileB= $Is_MacOSC= $Is_DOSishD= grep {$file =~ /$_$/i;} @path_ext[1 .. $#path_ext]E= -e _F= not -d _
ABCDEFresult
000XXX0
0010XX0
01XX0X0
00110X0
1XXXX00
01XX100
0011100
1XXXX11
01XX111
0011111
91 ($Is_MacOS || # MacOS doesn't mark as executable so we check -e
92 0 ($Is_DOSish and grep { $file =~ /$_$/i } @path_ext[1..$#path_ext])
93 # DOSish systems don't pass -x on non-exe/bat/com files.
94 # so we check -e. However, we don't want to pass -e on files
95 # that aren't in PATHEXT, like README.
96 and -e _)
97 ) and !-d _)
98 { # and finally, we don't want dirs to pass (as they are -x)
99  
100  
101 0 ▶ return $file unless $all;
Branch: 1 branch
BranchTrueFalseTotal
unless $all 0 0 0
102 0 push @results, $file; # Make list to return later
103 }
104 }
105 }
106
107 0 ▶ if($all) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all) { } 0 0 0
108 0 return @results;
109 } else {
110 0 return undef;
111 }
112 }
113  
114 ## End File::Which code
115  
116 sub check_path {
117
118 0 ▶ return add_link('local', which("$_[0]")) if which("$_[0]");
Subroutine check_path: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if which("$_[0]") 0 0 0
119 0 return "<i>not in path</i>";
120  
121 }
122  
123 sub match_string {
124 0 ▶ my($module_name, $string) = @_;
Subroutine match_string: not called CC=5 SCAR=34.0
Pod undocumented
125
126 0 my $result = 0;
127 0 ▶ my @string = (ref $string eq 'ARRAY') ? @$string : ($string);
Branch: 1 branch
BranchTrueFalseTotal
ref $string eq 'ARRAY' ? : 0 0 0
128 0 foreach(@string) {
129 0 $result = index(lc($module_name), lc($_));
130 0 ▶ last if ($result != -1);
Branch: 1 branch
BranchTrueFalseTotal
if $result != -1 0 0 0
131 }
132 0 ▶ return ($result == -1) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$result == -1 ? : 0 0 0
133  
134 }
135  
136 sub perl_version {
137 1 ▶ my $version;
Subroutine perl_version: called CC=2 SCAR=7.4
Pod undocumented
138 1 ▶ if ($] >= 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.006) { } 1 0 1
139 1 $version = sprintf "%vd", $^V;
140 }
141 else { # else time to update Perl!
142 0 $version = "$]";
143 }
144 1 return $version;
145 }
146  
147 sub release_date {
148  
149 # when things escaped
150 1 ▶ my %released = (
Subroutine release_date: called CC=4 SCAR=16.4
Pod undocumented
151 5.000 => '1994-10-17',
152 5.001 => '1995-03-14',
153 5.002 => '1996-02-96',
154 5.00307 => '1996-10-10',
155 5.004 => '1997-05-15',
156 5.005 => '1998-07-22',
157 5.00503 => '1999-03-28',
158 5.00405 => '1999-04-29',
159 5.006 => '2000-03-22',
160 5.006001 => '2001-04-08',
161 5.007003 => '2002-03-05',
162 5.008 => '2002-07-19',
163 5.008001 => '2003-09-25',
164 5.009 => '2003-10-27',
165 5.008002 => '2003-11-05',
166 5.006002 => '2003-11-15',
167 5.008003 => '2004-01-14',
168 5.00504 => '2004-02-23',
169 5.009001 => '2004-03-16',
170 5.008004 => '2004-04-21',
171 5.008005 => '2004-07-19',
172 5.008006 => '2004-11-27',
173 5.009002 => '2005-04-01',
174 5.008007 => '2005-05-30',
175 5.009003 => '2006-01-28',
176 5.008008 => '2006-01-31',
177 5.009004 => '2006-08-15',
178 5.009005 => '2007-07-07',
179 5.010000 => '2007-12-18',
180 );
181
182 # Do we have Module::Corelist
183 1 eval{require Module::CoreList};
184 1 ▶ if ($@) { # no
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 1 1
185 0 ▶ return ($released{$]}) ? $released{$]} : "unknown";
Branch: 1 branch
BranchTrueFalseTotal
$released{$]} ? : 0 0 0
186 }
187 else { # yes
188 1 ▶ return ($Module::CoreList::released{$]}) ? $Module::CoreList::released{$]} : "unknown";
Branch: 1 branch
BranchTrueFalseTotal
$Module::CoreList::released{$]} ? : 1 0 1
189 }
190
191 }
192  
193 sub check_args {
194  
195 0 ▶ my ($key, $value) = @_;
Subroutine check_args: not called CC=5 SCAR=34.0
Pod undocumented
196 0 my ($message, %allowed);
197 0 @allowed{qw(docs local 0 1)} = ();
198  
199 0 ▶ if (not exists $allowed{$key}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $allowed{$key}) { } 0 0 0
elsif ($key =~ /(?:docs|local)/ and not $value =~ /^(?:0|1)$/i) { } 0 0 0
200 0 $message = "$key is an invalid links parameter";
201 }
202 ▶ elsif ($key =~ /(?:docs|local)/ && $value !~ /^(?:0|1)$/i) {
Condition0%0/3
$key =~ /(?:docs|local)/ and not $value =~ /^(?:0|1)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
$key =~ /(?:docs|local)/ and not $value =~ /^(?:0|1)$/i
$key =~ /(?:docs|local)/ not $value =~ /^(?:0|1)$/i
Truth table0%0/3
A and not(B)
A= $key =~ /(?:docs|local)/B= not $value =~ /^(?:0|1)$/i
ABresult
0X0
100
111
203 0 $message = "$value is an invalid value for the $key parameter in the links attribute";
204 }
205  
206 0 ▶ error_msg("$message") if $message;
Branch: 1 branch
BranchTrueFalseTotal
if $message 0 0 0
207  
208 }
209  
210 sub check_module_args {
211  
212 0 ▶ my ($key, $value) = @_;
Subroutine check_module_args: not called CC=24 SCAR=64.0
Pod undocumented
213 0 my ($message, %allowed);
214 0 @allowed{qw(from columns sort_by color link show_only section full_page show_inc show_dir files_in)} = ();
215  
216 0 ▶ if (not exists $allowed{$key}) {
Branch: 9 branches
BranchTrueFalseTotal
if (not exists $allowed{$key}) { } 0 0 0
elsif ($key eq 'sort_by' and not $value =~ /^(?:name|version)$/i) { } 0 0 0
elsif ($key =~ /^(?:color|link|columns|files_in)$/ and ref $value ne 'ARRAY') { } 0 0 0
elsif ($key eq 'columns' and grep((!/^(?:name|version|desc|path|core)$/), @{$value;})) { } 0 0 0
elsif ($key eq 'color' and @{$value;} <= 1) { } 0 0 0
elsif ($key eq 'link' and @{$value;} <= 1 and $value->[0] != 0) { } 0 0 0
elsif ($key eq 'show_only' and ref $value ne 'ARRAY' and lc $value ne 'core') { } 0 0 0
elsif ($key eq 'full_page' and $value != 0 and $value != 1) { } 0 0 0
elsif ($key eq 'link' and ($value->[0] ne 'all' and $value->[0] != 0 and ref $value->[0] ne 'ARRAY')) { } 0 0 0
217 0 $message = "$key is an invalid print_modules parameter";
218 }
219 ▶ elsif ($key eq 'sort_by' && $value !~ /^(?:name|version)$/i) {
Condition0%0/3
$key eq "sort_by" and not $value =~ /^(?:name|version)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "sort_by" and not $value =~ /^(?:name|version)$/i
$key eq "sort_by" not $value =~ /^(?:name|version)$/i
Truth table0%0/3
A and not(B)
A= $key eq "sort_by"B= not $value =~ /^(?:name|version)$/i
ABresult
0X0
100
111
220 0 $message = "$value is an invalid sort";
221 }
222 ▶ elsif ($key =~ /^(?:color|link|columns|files_in)$/ && ref($value) ne 'ARRAY') {
Condition0%0/3
$key =~ /^(?:color|link|columns|files_in)$/ and ref $value ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$key =~ /^(?:color|link|columns|files_in)$/ and ref $value ne "ARRAY"
$key =~ /^(?:color|link|columns|files_in)$/ ref $value ne "ARRAY"
Truth table0%0/3
A and B
A= $key =~ /^(?:color|link|columns|files_in)$/B= ref $value ne "ARRAY"
ABresult
0X0
100
111
223 0 $message = "The $key parameter value is not an array reference";
224 }
225 0 ▶ elsif ($key eq 'columns' && grep(!/^(?:name|version|desc|path|core)$/, @{$value})) {
Condition0%0/3
$key eq "columns" and grep((!/^(?:name|version|desc|path|core)$/), @{$value;})
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "columns" and grep((!/^(?:name|version|desc|path|core)$/), @{$value;})
$key eq "columns" grep((!/^(?:name|version|desc|path|core)$/), @{$value;})
Truth table0%0/3
A and B
A= $key eq "columns"B= grep((!/^(?:name|version|desc|path|core)$/), @{$value;})
ABresult
0X0
100
111
226 0 $message = "Invalid column name in the $key parameter";
227 }
228 0 ▶ elsif ($key eq 'color' && @{$value} <= 1) {
Condition0%0/3
$key eq "color" and @{$value;} <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "color" and @{$value;} <= 1
$key eq "color" @{$value;} <= 1
Truth table0%0/3
A and B
A= $key eq "color"B= @{$value;} <= 1
ABresult
0X0
100
111
229 0 $message = "You didn't specify a module to color";
230 }
231 0 ▶ elsif ($key eq 'link' && @{$value} <= 1 && $value->[0] != 0) {
Condition0%0/6
$key eq "link" and @{$value;} <= 1 and $value->[0] != 0
!ll&&!rl&&r
000
$key eq "link" and @{$value;} <= 1
!ll&&!rl&&r
000
MC/DC0%0/3
$key eq "link" and @{$value;} <= 1 and $value->[0] != 0
$key eq "link" @{$value;} <= 1 $value->[0] != 0
Truth table0%0/4
A and B and C
A= $key eq "link"B= @{$value;} <= 1C= $value->[0] != 0
ABCresult
0XX0
10X0
1100
1111
232 0 $message = "You didn't provide a URL for the $key parameter";
233 }
234 ▶ elsif ($key eq 'show_only' && (ref($value) ne 'ARRAY') && lc $value ne 'core') {
Condition0%0/6
$key eq "show_only" and ref $value ne "ARRAY" and lc $value ne "core"
!ll&&!rl&&r
000
$key eq "show_only" and ref $value ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
$key eq "show_only" and ref $value ne "ARRAY" and lc $value ne "core"
$key eq "show_only" ref $value ne "ARRAY" lc $value ne "core"
Truth table0%0/4
A and B and C
A= $key eq "show_only"B= ref $value ne "ARRAY"C= lc $value ne "core"
ABCresult
0XX0
10X0
1100
1111
235 0 $message = "$value is an invalid value for the $key parameter";
236 }
237 ▶ elsif ($key eq 'full_page' && $value != 0 && $value != 1 ) {
Condition0%0/6
$key eq "full_page" and $value != 0 and $value != 1
!ll&&!rl&&r
000
$key eq "full_page" and $value != 0
!ll&&!rl&&r
000
MC/DC0%0/3
$key eq "full_page" and $value != 0 and $value != 1
$key eq "full_page" $value != 0 $value != 1
Truth table0%0/4
A and B and C
A= $key eq "full_page"B= $value != 0C= $value != 1
ABCresult
0XX0
10X0
1100
1111
238 0 $message = "$value is an invalid value for the $key parameter";
239 }
240 ▶ elsif ($key eq 'link' && ($value->[0] ne 'all' && $value->[0] != 0 && ref($value->[0]) ne 'ARRAY')) {
Condition0%0/9
$key eq "link" and ($value->[0] ne "all" and $value->[0] != 0 and ref $value->[0] ne "ARRAY")
!ll&&!rl&&r
000
$value->[0] ne "all" and $value->[0] != 0 and ref $value->[0] ne "ARRAY"
!ll&&!rl&&r
000
$value->[0] ne "all" and $value->[0] != 0
!ll&&!rl&&r
000
MC/DC0%0/4
$key eq "link" and ($value->[0] ne "all" and $value->[0] != 0 and ref $value->[0] ne "ARRAY")
$key eq "link" $value->[0] ne "all" $value->[0] != 0 ref $value->[0] ne "ARRAY"
Truth table0%0/5
A and B and C and D
A= $key eq "link"B= $value->[0] ne "all"C= $value->[0] != 0D= ref $value->[0] ne "ARRAY"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
241 0 $message = "Invalid first element in the $key parameter value";
242 }
243 0 ▶ error_msg("$message") if $message;
Branch: 1 branch
BranchTrueFalseTotal
if $message 0 0 0
244 }
245  
246  
247  
248 sub process_args {
249 # This sub returns a hash ref containing param args
250 0 ▶ my %params;
Subroutine process_args: not called CC=6 SCAR=37.4
Pod undocumented
251 0 ▶ my $sub = pop @_ || die "No coderef provided\n"; # get the sub
Condition0%0/2
pop @_ || die("No coderef provided\n")
l!l
00
MC/DC0%0/1
pop @_ || die("No coderef provided\n")
pop @_
Truth table0%0/2
A
A= pop @_
Aresult
11
00
252 0 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
253 0 ▶ while(my($key, $value) = splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 0 0 0
254 0 $sub->($key, $value);
255 0 ▶ if (exists $params{$key}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params{$key}) { } 0 0 0
256 0 ▶ my @key_value = ref(${$params{$key}}[0]) eq 'ARRAY' ? @{$params{$key}} : $params{$key};
Branch: 1 branch
BranchTrueFalseTotal
ref do { $params{$key} }->[0] eq 'ARRAY' ? : 0 0 0
257 0 push @key_value,$value;
258 0 my $new_val = [@key_value];
259 0 $params{$key} = $new_val;
260 }
261 else {
262 0 $params{$key} = $value;
263 }
264 }
265 }
266 0 return \%params;
267 }
268  
269 sub error_msg {
270 0 ▶ local $Carp::CarpLevel = $Carp::CarpLevel + 1;
Subroutine error_msg: not called CC=1 SCAR=6.9
Pod undocumented
271 0 Carp::croak "User error: $_[0]";
272 }
273  
274 # HTML subs
275  
276 sub print_table_colspan_header {
277
278 0 ▶ return sprintf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", $_[0], $_[1]);
Subroutine print_table_colspan_header: not called CC=1 SCAR=6.9
Pod undocumented
279  
280 }
281  
282 sub print_table_row {
283
284
285 1283 ▶ my $num_cols = $_[0];
Subroutine print_table_row: called CC=5 SCAR=16.4
Pod undocumented
286 1283 my $HTML = "<tr>";
287  
288 1283 ▶ for (my $i=0; $i<$num_cols; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_cols) 2566 1283 3849
289  
290 2566 ▶ $HTML .= sprintf("<td class=\"%s\">", ($i==0 ? "e" : "v" ));
Branch: 1 branch
BranchTrueFalseTotal
$i == 0 ? : 1283 1283 2566
291  
292 2566 my $row_element = $_[$i+1];
293 2566 ▶ if ((not defined ($row_element)) || ($row_element !~ /\S/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $row_element && $row_element =~ /\S/) { } 0 2566 2566
Condition33%1/3
defined $row_element && $row_element =~ /\S/
!ll&&!rl&&r
002566
MC/DC0%0/2
defined $row_element && $row_element =~ /\S/
defined $row_element $row_element =~ /\S/
Truth table33%1/3
A && B
A= defined $row_elementB= $row_element =~ /\S/
ABresult
0X0
100
111
294 0 $HTML .= "<i>no value</i>";
295 } else {
296 2566 my $elem_esc = $row_element;
297 2566 $HTML .= "$elem_esc";
298  
299 }
300  
301 2566 $HTML .= " </td>";
302  
303 }
304  
305 1283 $HTML .= "</tr>\n";
306 1283 return $HTML;
307
308 }
309  
310  
311 sub print_table_color_start {
312  
313 0 ▶ return qq~<table class="modules" cellpadding=4 cellspacing=4 border=0 width="600"><tr>\n~;
Subroutine print_table_color_start: not called CC=1 SCAR=6.9
Pod undocumented
314 }
315  
316 sub print_table_color_end {
317  
318 0 ▶ return '</tr></table>';
Subroutine print_table_color_end: not called CC=1 SCAR=6.9
Pod undocumented
319 }
320  
321  
322 sub print_color_box {
323  
324 0 ▶ return qq ~<td>
Subroutine print_color_box: not called CC=1 SCAR=6.9
Pod undocumented
325 <table border=0>
326 <tr><td>
327 <table class="modules" border=0 width=50 height=50 align=left bgcolor="$_[0]">
328 <tr bgcolor="$_[0]">
329 <td color="$_[0]">
330 &nbsp;
331 </td>
332 </tr>
333 </table>
334 </tr></td>
335 <tr><td><small>$_[1]</small></td></tr>
336 </table>
337 </td>~;
338 }
339  
340 sub print_table_row_color {
341  
342 0 ▶ my $num_cols = $_[0];
Subroutine print_table_row_color: not called CC=7 SCAR=40.3
Pod undocumented
343 0 ▶ my $HTML = $_[1] ? "<tr bgcolor=\"$_[1]\">" : "<tr>";
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
344  
345 0 ▶ for (my $i=0; $i<$num_cols; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_cols) 0 0 0
346  
347 0 ▶ $HTML .= $_[1] ? "<td bgcolor=\"$_[1]\">" : sprintf("<td class=\"%s\">", ($i==0 ? "e" : "v" ));
Branch: 2 branches
BranchTrueFalseTotal
$_[1] ? : 0 0 0
$i == 0 ? : 0 0 0
348  
349 0 my $row_element = $_[$i+2]; # start at the 2nd element
350 0 ▶ if ((not defined ($row_element)) || ($row_element !~ /\S/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $row_element && $row_element =~ /\S/) { } 0 0 0
Condition0%0/3
defined $row_element && $row_element =~ /\S/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $row_element && $row_element =~ /\S/
defined $row_element $row_element =~ /\S/
Truth table0%0/3
A && B
A= defined $row_elementB= $row_element =~ /\S/
ABresult
0X0
100
111
351 0 $HTML .= "<i>no value</i>";
352 } else {
353 0 my $elem_esc = $row_element;
354 0 $HTML .= "$elem_esc";
355  
356 }
357  
358 0 $HTML .= " </td>";
359  
360 }
361  
362 0 $HTML .= "</tr>\n";
363 0 return $HTML;
364 }
365
366 sub print_table_start {
367  
368 6 ▶ return "<table border=\"0\" cellpadding=\"3\" width=\"600\">\n";
Subroutine print_table_start: called CC=1 SCAR=0.0
Pod undocumented
369  
370 }
371 sub print_table_end {
372  
373 6 ▶ return "</table><br />\n";
Subroutine print_table_end: called CC=1 SCAR=0.0
Pod undocumented
374  
375 }
376 sub print_box_start {
377  
378 3 ▶ my $HTML = print_table_start();
Subroutine print_box_start: called CC=2 SCAR=6.9
Pod undocumented
379 3 ▶ $HTML .= ($_[0] == 1) ? "<tr class=\"h\"><td>\n" : "<tr class=\"v\"><td>\n";
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 ? : 1 2 3
380 3 return $HTML;
381 }
382  
383  
384 sub print_box_end {
385 3 ▶ my $HTML = "</td></tr>\n";
Subroutine print_box_end: called CC=1 SCAR=0.0
Pod undocumented
386 3 $HTML .= print_table_end();
387 3 return $HTML;
388 }
389  
390 sub print_hr {
391 0 ▶ return "<hr />\n";
Subroutine print_hr: not called CC=1 SCAR=6.9
Pod undocumented
392  
393 }
394  
395  
396 sub print_table_header {
397  
398 2 ▶ my($num_cols) = $_[0];
Subroutine print_table_header: called CC=3 SCAR=11.0
Pod undocumented
399 2 my $HTML = "<tr class=\"h\">";
400  
401 2 my $i;
402 2 ▶ for ($i=0; $i<$num_cols; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_cols) 4 2 6
403 4 my $row_element = $_[$i+1];
404 4 ▶ $row_element = " " if (!$row_element);
Branch: 1 branch
BranchTrueFalseTotal
unless $row_element 0 4 4
405 4 $HTML .= "<th>$row_element</th>";
406 }
407  
408 2 return "$HTML</tr>\n";
409 }
410  
411  
412 sub print_section {
413  
414 3 ▶ return "<h2>" . $_[0] . "</h2>\n";
Subroutine print_section: called CC=1 SCAR=0.0
Pod undocumented
415  
416 }
417  
418
419  
420 sub print_perl_license {
421  
422 1 ▶ return <<"END_OF_HTML";
Subroutine print_perl_license: called CC=1 SCAR=0.0
Pod undocumented
423 <p>
424 This program is free software; you can redistribute it and/or modify it under the terms of
425 either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
426 </p>
427  
428 <p>
429 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
430 </p>
431 <p>
432 Complete documentation for Perl, including FAQ lists, should be found on
433 this system using `man perl' or `perldoc perl'. If you have access to the
434 1 Internet, point your browser at @{[ add_link('same', 'http://www.perl.org/')]}, the Perl directory.
435 </p>
436 END_OF_HTML
437  
438 }
439  
440 sub print_license {
441  
442 1 ▶ return join '', print_section("Perl License"),
Subroutine print_license: called CC=1 SCAR=0.0
Pod undocumented
443 print_box_start(0),
444 print_perl_license(),
445 print_box_end();
446 }
447  
448  
449 sub add_link {
450  
451 1665 ▶ my ($type, $value, $link) = @_;
Subroutine add_link: called CC=27 SCAR=60.7
Pod undocumented
452 1665 ▶ return $value unless $links{'all'};
Branch: 1 branch
BranchTrueFalseTotal
unless $HTML::Perlinfo::Common::links{"all"} 0 1665 1665
453
454 1665 ▶ if ($type eq "cpan") {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'cpan') { } 0 1665 1665
elsif ($type eq 'config') { } 1664 1 1665
elsif ($type eq 'local') { } 0 1 1
elsif ($type eq 'same') { } 1 0 1
455  
456 0 ▶ return $value if $link && $link->[0] =~ /^[0]$/;
Branch: 1 branch
BranchTrueFalseTotal
if $link and $link->[0] =~ /^[0]$/ 0 0 0
Condition0%0/3
$link and $link->[0] =~ /^[0]$/
!ll&&!rl&&r
000
MC/DC0%0/2
$link and $link->[0] =~ /^[0]$/
$link $link->[0] =~ /^[0]$/
Truth table0%0/3
A and B
A= $linkB= $link->[0] =~ /^[0]$/
ABresult
0X0
100
111
457
458 0 ▶ if ($link) {
Branch: 1 branch
BranchTrueFalseTotal
if ($link) 0 0 0
459 0 ▶ if (ref $link->[0] eq 'ARRAY' && ref $link->[1] ne 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $link->[0] eq 'ARRAY' and ref $link->[1] ne 'ARRAY') { } 0 0 0
elsif (ref $link->[0] eq 'ARRAY' and ref $link->[1] eq 'ARRAY') { } 0 0 0
elsif ($link->[0] eq 'all' or match_string($value, $link->[0]) == 1) { } 0 0 0
Condition0%0/3
ref $link->[0] eq "ARRAY" and ref $link->[1] ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $link->[0] eq "ARRAY" and ref $link->[1] ne "ARRAY"
ref $link->[0] eq "ARRAY" ref $link->[1] ne "ARRAY"
Truth table0%0/3
A and B
A= ref $link->[0] eq "ARRAY"B= ref $link->[1] ne "ARRAY"
ABresult
0X0
100
111
460 0 foreach (@{$link->[0]}) {
461 0 ▶ if ($_ eq 'all' or match_string($value,$_)==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "all" or match_string($value, $_) == 1) 0 0 0
Condition0%0/3
$_ eq "all" or match_string($value, $_) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq "all" or match_string($value, $_) == 1
$_ eq "all" match_string($value, $_) == 1
Truth table0%0/3
A or B
A= $_ eq "all"B= match_string($value, $_) == 1
ABresult
1X1
011
000
462 0 return '<a href=' . $link->[1] . $value .
463 qq~ title="Click here to see $value documentation [Opens in a new window]"
464 target="_blank">$value</a> ~
465 }
466 }
467 }
468 ▶ elsif (ref $link->[0] eq 'ARRAY' && ref $link->[1] eq 'ARRAY'){
Condition0%0/3
ref $link->[0] eq "ARRAY" and ref $link->[1] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $link->[0] eq "ARRAY" and ref $link->[1] eq "ARRAY"
ref $link->[0] eq "ARRAY" ref $link->[1] eq "ARRAY"
Truth table0%0/3
A and B
A= ref $link->[0] eq "ARRAY"B= ref $link->[1] eq "ARRAY"
ABresult
0X0
100
111
469 0 foreach my $lv (@$link) {
470 0 ▶ if (ref $lv->[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $lv->[0] eq 'ARRAY') { } 0 0 0
471 0 foreach(@{$lv->[0]}) {
472 0 ▶ if ($_ eq 'all' or match_string($value,$_)==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "all" or match_string($value, $_) == 1) 0 0 0
Condition0%0/3
$_ eq "all" or match_string($value, $_) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq "all" or match_string($value, $_) == 1
$_ eq "all" match_string($value, $_) == 1
Truth table0%0/3
A or B
A= $_ eq "all"B= match_string($value, $_) == 1
ABresult
1X1
011
000
473 0 return '<a href=' . $lv->[1] . $value .
474 qq~ title="Click here to see $value documentation [Opens in a new window]"
475 target="_blank">$value</a> ~
476 }
477 }
478 }
479 else {
480 0 ▶ if ($lv->[0] eq 'all' or match_string($value,$lv->[0])==1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lv->[0] eq "all" or match_string($value, $lv->[0]) == 1) 0 0 0
Condition0%0/3
$lv->[0] eq "all" or match_string($value, $lv->[0]) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$lv->[0] eq "all" or match_string($value, $lv->[0]) == 1
$lv->[0] eq "all" match_string($value, $lv->[0]) == 1
Truth table0%0/3
A or B
A= $lv->[0] eq "all"B= match_string($value, $lv->[0]) == 1
ABresult
1X1
011
000
481 0 return '<a href=' . $lv->[1] . $value .
482 qq~ title="Click here to see $value documentation [Opens in a new window]"
483 target="_blank">$value</a> ~
484 }
485 }
486 }
487 }
488 ▶ elsif ($link->[0] eq 'all' or match_string($value,$link->[0])==1) {
Condition0%0/3
$link->[0] eq "all" or match_string($value, $link->[0]) == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$link->[0] eq "all" or match_string($value, $link->[0]) == 1
$link->[0] eq "all" match_string($value, $link->[0]) == 1
Truth table0%0/3
A or B
A= $link->[0] eq "all"B= match_string($value, $link->[0]) == 1
ABresult
1X1
011
000
489 0 return '<a href=' . $link->[1] . $value .
490 qq~ title="Click here to see $value documentation [Opens in a new window]"
491 target="_blank">$value</a> ~
492 }
493 }
494 0 return qq~ <a href="https://metacpan.org/pod/$value"
495 title="Click here to see $value on CPAN [Opens in a new window]" target="_blank">$value</a> ~;
496 }
497 elsif ($type eq "config") {
498 1664 ▶ return $value unless $links{'docs'};
Branch: 1 branch
BranchTrueFalseTotal
unless $HTML::Perlinfo::Common::links{"docs"} 0 1664 1664
499 1664 my ($letter) = $value =~ /^(.)/;
500 1664 return qq! <a href="http://search.cpan.org/~aburlison/Solaris-PerlGcc-1.3/config/5.006001/5.10/sparc/Config.pm#$letter">$value</a> !;
501 }
502 elsif ($type eq "local") {
503 0 ▶ return $value unless $links{'local'};
Branch: 1 branch
BranchTrueFalseTotal
unless $HTML::Perlinfo::Common::links{"local"} 0 0 0
504 0 return qq~ <a href="file://$value" title="Click here to see $value [Opens in a new window]" target="_blank">$value</a> ~;
505 }
506 elsif ($type eq "same") {
507 1 return qq~ <a href="$value">$value</a> ~;
508 }
509 }
510  
511 5 1;
↑ Summary Perlinfo/Modules.pm »