Plient/Util.pm

filter: Statementstmt 87.5% 35 / 40 Branchbran 33.3% 2 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 75.0% 45 / 60 CC 7 SCAR 20.1
CC
7
Cov
76%
which
14.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.5
« Plient/Test.pm ↑ Summary Plient/Protocol/File.pm »
1 package Plient::Util;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use File::Spec::Functions;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 our @EXPORT = 'which';
11  
12 5 ▶use constant WIN32 => $^O eq 'MSWin32';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 my $bin_quote = WIN32 ? q{"} : q{'};
14 5 my $bin_ext = $Config{_exe};
15 5 my %cache;
16 3 ▶sub which {
Subroutine which: called CC=7 SCAR=26.4
Pod undocumented
17 3 my $name = shift;
18 3 ▶ return $cache{$name} if $cache{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $cache{$name} 0 3 3
19  
20 3 my $path;
21  
22 LINE:
23 3 for my $dir ( path() ) {
24 30 my $p = catfile( $dir, $name );
25  
26 # XXX any other names need to try?
27 30 my @try = grep { -x } ( $p, $p . $bin_ext );
28 30 for my $try (@try) {
29 0 $path = $try;
30 0 last LINE;
31 }
32 }
33  
34 3 ▶ return unless $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $path 3 0 3
35 0 ▶ if ( $path =~ /\s/ && $path !~ /^$bin_quote/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /\s/ and not $path =~ /^$bin_quote/) 0 0 0
Condition0%0/3
$path =~ /\s/ and not $path =~ /^$bin_quote/
!ll&&!rl&&r
000
MC/DC0%0/2
$path =~ /\s/ and not $path =~ /^$bin_quote/
$path =~ /\s/ not $path =~ /^$bin_quote/
Truth table0%0/3
A and not(B)
A= $path =~ /\s/B= not $path =~ /^$bin_quote/
ABresult
0X0
100
111
36 0 $path = $bin_quote . $path . $bin_quote;
37 }
38  
39 0 return $cache{$name} = $path;
40 }
41  
42 5 1;
43  
44 __END__
« Plient/Test.pm ↑ Summary Plient/Protocol/File.pm »