| 1 | package File::Random; | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Want qw/howmany/; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||
| 16 | ':all' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||
| 17 | random_file | ||||||||||||||||||||||||||||||||||||||||||||
| 18 | content_of_random_file corf | ||||||||||||||||||||||||||||||||||||||||||||
| 19 | random_line | ||||||||||||||||||||||||||||||||||||||||||||
| 20 | ) ], | ||||||||||||||||||||||||||||||||||||||||||||
| 21 | # and for some backward compability | ||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'all' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||
| 23 | random_file | ||||||||||||||||||||||||||||||||||||||||||||
| 24 | content_of_random_file corf | ||||||||||||||||||||||||||||||||||||||||||||
| 25 | random_line | ||||||||||||||||||||||||||||||||||||||||||||
| 26 | ) ] | ||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{':all'} }, 'corf' ); | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | our $VERSION = '0.20'; | |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub _standard_dir($); | ||||||||||||||||||||||||||||||||||||||||||||
| 37 | sub _dir(%); | ||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub random_file { | ||||||||||||||||||||||||||||||||||||||||||||
| 40 | 36620 | ▶ | my @params = my ($dir, $check, $recursive, $follow) = _params_random_file(@_); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
random_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 36566 | ▶ | return $recursive ? _random_file_recursive (@params) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 43 | : _random_file_non_recursive(@params); | ||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | *corf = *content_of_random_file; | |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | sub content_of_random_file { | ||||||||||||||||||||||||||||||||||||||||||||
| 49 | 18560 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_of_random_file: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 18560 | ▶ | my $rf = random_file(%args) or return undef; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 16250 | my $dir = _standard_dir _dir %args; | |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 16250 | ▶ | open RANDOM_FILE, "<", "$dir/$rf" | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 54 | or die "Can't open the randomly selected file '$dir/$rf'"; | ||||||||||||||||||||||||||||||||||||||||||||
| 55 | 16250 | my @content = (<RANDOM_FILE>); | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 16250 | close RANDOM_FILE; | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 16250 | ▶ | return wantarray ? @content : join "", @content; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | sub random_line { | ||||||||||||||||||||||||||||||||||||||||||||
| 61 | 345 | ▶ | my ($fname, $nr_of_lines) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
random_line: called CC=19 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 345 | ▶ | defined $fname or die "Need a defined filename to read a random line"; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 344 | ▶ | if (!defined($nr_of_lines) and wantarray) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $nr_of_lines and wantarray
MC/DC100%2/2
not defined $nr_of_lines and wantarray
not defined $nr_of_lines
wantarray
Truth table100%3/3
not(A) and B
A= not defined $nr_of_linesB= wantarray
| |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 68 | ▶ | $nr_of_lines = howmany() || 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&howmany() || 1
MC/DC100%1/1
&howmany() || 1
&howmany()
Truth table100%2/2
A
A= &howmany()
| |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 66 | 344 | ▶ | unless (!defined($nr_of_lines) or $nr_of_lines =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $nr_of_lines or $nr_of_lines =~ /^\d+$/
MC/DC100%2/2
not defined $nr_of_lines or $nr_of_lines =~ /^\d+$/
not defined $nr_of_lines
$nr_of_lines =~ /^\d+$/
Truth table100%3/3
not(A) or B
A= not defined $nr_of_linesB= $nr_of_lines =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | die "Number of random_lines should be a number, not '$nr_of_lines'"; | |||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 69 | 342 | ▶ | defined($nr_of_lines) and $nr_of_lines == 0 and | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $nr_of_lines and $nr_of_lines == 0
MC/DC100%2/2
defined $nr_of_lines and $nr_of_lines == 0
defined $nr_of_lines
$nr_of_lines == 0
Truth table100%3/3
A and B
A= defined $nr_of_linesB= $nr_of_lines == 0
| |||||||||||||||||||||||||||||||||||||||||||||
| 70 | carp "doesn't make a lot of sense to return 0 random lines, " . | ||||||||||||||||||||||||||||||||||||||||||||
| 71 | "you called me with random_line($fname,$nr_of_lines)"; | ||||||||||||||||||||||||||||||||||||||||||||
| 72 | 342 | ▶ | $nr_of_lines ||= 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$nr_of_lines ||= 1
MC/DC100%1/1
$nr_of_lines ||= 1
$nr_of_lines
Truth table100%2/2
A
A= $nr_of_lines
| |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 342 | my @line = (); | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 342 | ▶ | open FILE, '<', $fname or die "Can't open '$fname' to read random_line"; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 340 | ▶ | if ($nr_of_lines == 1) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Algorithm from Cookbook, chapter 8.6 | ||||||||||||||||||||||||||||||||||||||||||||
| 77 | 203 | ▶ | rand($.) < 1 && ($line[0] = $_) while (<FILE>); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 79 | wantarray or | ||||||||||||||||||||||||||||||||||||||||||||
| 80 | 137 | ▶ | carp "random_line($fname,$nr_of_lines) was called in scalar context, ". | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 81 | "what doesn't make a lot sense"; | ||||||||||||||||||||||||||||||||||||||||||||
| 82 | 137 | ▶ | while (<FILE>) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1096 | for my $lnr (0 .. $nr_of_lines-1) { | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 5640 | ▶ | $line[$lnr] = $_ if rand($.) < 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 88 | 340 | close FILE; | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 340 | ▶ | return wantarray ? @line : $line[0]; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _random_file_non_recursive { | ||||||||||||||||||||||||||||||||||||||||||||
| 93 | 24316 | ▶ | my ($dir, $check) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_file_non_recursive: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 24316 | ▶ | opendir DIR, $dir or die "Can't open directory '$dir'"; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 24298 | ▶ | my @files = grep {-f "$dir/$_" and _valid_file($check, $_)} (readdir DIR); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 24298 | closedir DIR; | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 24298 | ▶ | return undef unless @files; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 19750 | return $files[rand @files]; | |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | sub _random_file_recursive { | ||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12250 | ▶ | my ($dir, $check, $recursive, $follow) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_file_recursive: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 12250 | my $i = 1; | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 12250 | my $fname; | |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | my $accept_routine = sub { | ||||||||||||||||||||||||||||||||||||||||||||
| 110 | 196000 | ▶ | return unless -f; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | # Calculate filename with relative path | ||||||||||||||||||||||||||||||||||||||||||||
| 113 | 147000 | my ($f) = $File::Find::name =~ m:^$dir[/\\]*(.*)$:; | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 147000 | ▶ | return unless _valid_file($check,$f); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 115 | # Algorithm from Cookbook, chapter 8.6 | ||||||||||||||||||||||||||||||||||||||||||||
| 116 | # similar to selecting a random line from a file | ||||||||||||||||||||||||||||||||||||||||||||
| 117 | 138000 | ▶ | if (rand($i++) < 1) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 36923 | $fname = $f; | |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 120 | 12250 | }; | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 12250 | find({wanted => $accept_routine, follow => $follow}, $dir); | |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 12250 | return $fname; | |||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | sub _valid_file { | ||||||||||||||||||||||||||||||||||||||||||||
| 127 | 275000 | ▶ | my ($check, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_file: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 275000 | for (ref($check)) { | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 275000 | ▶ | /Regexp/ && return $name =~ /$check/ | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition57%4/7
/Regexp/ && (return $name =~ /$check/) || /CODE/ && ($_ = $name, (return &$check($name)))
/Regexp/ and return $name =~ /$check/
/CODE/ and $_ = $name, (return &$check($name))
MC/DC0%0/3
/Regexp/ && (return $name =~ /$check/) || /CODE/ && ($_ = $name, (return &$check($name)))
/Regexp/
/CODE/
$_ = $name, (return &$check($name))
Truth table0%0/4
A || B and C
A= /Regexp/B= /CODE/C= $_ = $name, (return &$check($name))
| |||||||||||||||||||||||||||||||||||||||||||||
| 130 | or /CODE/ && ($_ = $name, return $check->($name)); | ||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | sub _dir (%) { | ||||||||||||||||||||||||||||||||||||||||||||
| 135 | 52834 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dir: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 52834 | ▶ | return $args{-d} || $args{-dir} || $args{-directory}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$args{'-d'} || $args{'-dir'} || $args{'-directory'}
$args{"-d"} or $args{"-dir"}
MC/DC100%3/3
$args{'-d'} || $args{'-dir'} || $args{'-directory'}
$args{"-d"}
$args{"-dir"}
$args{'-directory'}
Truth table100%4/4
A or B || C
A= $args{"-d"}B= $args{"-dir"}C= $args{'-directory'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | sub _params_random_file { | ||||||||||||||||||||||||||||||||||||||||||||
| 140 | 36620 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_params_random_file: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 36620 | for (qw/-d -dir -directory -c -check/) { | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 183040 | ▶ | exists $args{$_} and ! $args{$_} and | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $args{$_} and not $args{$_}
MC/DC100%2/2
exists $args{$_} and not $args{$_}
exists $args{$_}
not $args{$_}
Truth table100%3/3
A and not(B)
A= exists $args{$_}B= not $args{$_}
| |||||||||||||||||||||||||||||||||||||||||||||
| 144 | die "Parameter $_ is declared with a false value"; | ||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 36584 | foreach (keys %args) { | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 75635 | ▶ | /^\-(d|dir|directory| | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 149 | c|check| | ||||||||||||||||||||||||||||||||||||||||||||
| 150 | r|rec|recursive| | ||||||||||||||||||||||||||||||||||||||||||||
| 151 | f|follow)$/x or carp "Unknown option '$_'"; | ||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 36584 | my $dir = _standard_dir _dir %args; | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 36584 | ▶ | my $check = $args{-c} || $args{-check} || sub {"always O.K."}; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition83%5/6
$args{'-c'} || $args{'-check'} || sub {
'always O.K.';
}
$args{"-c"} or $args{"-check"}
MC/DC0%0/3
$args{'-c'} || $args{'-check'} || sub {
'always O.K.';
}
$args{"-c"}
$args{"-check"}
sub {
'always O.K.';
}
Truth table75%3/4
A or B || C
A= $args{"-c"}B= $args{"-check"}C= sub {
'always O.K.';
}
| |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 36584 | ▶ | my $recursive = $args{-r} || $args{-rec} || $args{-recursive}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$args{'-r'} || $args{'-rec'} || $args{'-recursive'}
$args{"-r"} or $args{"-rec"}
MC/DC100%3/3
$args{'-r'} || $args{'-rec'} || $args{'-recursive'}
$args{"-r"}
$args{"-rec"}
$args{'-recursive'}
Truth table100%4/4
A or B || C
A= $args{"-r"}B= $args{"-rec"}C= $args{'-recursive'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 36584 | ▶ | my $follow = $args{-f} || $args{-follow}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'-f'} || $args{'-follow'}
MC/DC0%0/2
$args{'-f'} || $args{'-follow'}
$args{'-f'}
$args{'-follow'}
Truth table33%1/3
A || B
A= $args{'-f'}B= $args{'-follow'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 36584 | ▶ | unless (!defined($check) or (scalar ref($check) =~ /^(Regexp|CODE)$/)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
not defined $check or scalar ref($check) =~ /^(Regexp|CODE)$/
MC/DC0%0/1
not defined $check or scalar ref($check) =~ /^(Regexp|CODE)$/
not defined $check
Truth table50%1/2
not(A)
A= not defined $check
| |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 18 | die "-check Parameter has to be either a Regexp or a sub routine,". | |||||||||||||||||||||||||||||||||||||||||||
| 161 | "not a '" . ref($check) . "'"; | ||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 36566 | return ($dir, $check, $recursive, $follow); | |||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | sub _standard_dir($) { | ||||||||||||||||||||||||||||||||||||||||||||
| 168 | 52834 | ▶ | my $dir = shift() || '.'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_standard_dir: called CC=2 SCAR=6.9
Condition100%2/2
shift() || '.'
MC/DC100%1/1
shift() || '.'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 52834 | $dir =~ s:[/\\]+$::; | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 52834 | return $dir; | |||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 174 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||