line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
619
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package File::Find::Upwards; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
16
|
$File::Find::Upwards::VERSION = '1.102030'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Look for a file in the current directory and upwards |
10
|
1
|
|
|
1
|
|
825
|
use Path::Class; |
|
1
|
|
|
|
|
62635
|
|
|
1
|
|
|
|
|
76
|
|
11
|
1
|
|
|
1
|
|
863
|
use Attribute::Memoize; |
|
1
|
|
|
|
|
7476
|
|
|
1
|
|
|
|
|
34
|
|
12
|
1
|
|
|
1
|
|
9
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
163
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw(file_find_upwards find_containing_dir_upwards); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub file_find_upwards : Memoize { |
16
|
4
|
|
|
4
|
|
926
|
my @wanted_files = @_; |
17
|
4
|
|
|
|
|
16
|
my $dir = dir('.')->absolute; |
18
|
4
|
|
|
|
|
774
|
my %seen; |
19
|
|
|
|
|
|
|
my $result; # left undef as we'll return undef if we didn't find it |
20
|
|
|
|
|
|
|
LOOP: { |
21
|
4
|
|
|
|
|
5
|
do { |
|
4
|
|
|
|
|
6
|
|
22
|
11
|
100
|
|
|
|
1076
|
last if $seen{$dir}++; |
23
|
10
|
|
|
|
|
194
|
for my $wanted_file (@wanted_files) { |
24
|
12
|
|
|
|
|
139
|
my $file = $dir->file($wanted_file); |
25
|
12
|
100
|
|
|
|
1197
|
if (-e $file) { |
26
|
3
|
|
|
|
|
165
|
$result = $file->absolute; |
27
|
3
|
|
|
|
|
135
|
last LOOP; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} while ($dir = $dir->parent); |
31
|
|
|
|
|
|
|
} |
32
|
4
|
|
|
|
|
54
|
$result; |
33
|
1
|
|
|
1
|
|
5
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub find_containing_dir_upwards : Memoize { |
36
|
2
|
|
|
2
|
|
6
|
my @wanted_files = @_; |
37
|
2
|
|
|
|
|
11
|
my $dir = dir('.')->absolute; |
38
|
2
|
|
|
|
|
298
|
my %seen; |
39
|
2
|
|
|
|
|
7
|
do { |
40
|
4
|
50
|
|
|
|
488
|
last if $seen{$dir}++; |
41
|
4
|
|
|
|
|
90
|
for my $wanted_file (@wanted_files) { |
42
|
6
|
100
|
|
|
|
278
|
return $dir if -e $dir->file($wanted_file); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} while ($dir = $dir->parent); |
45
|
0
|
|
|
|
|
|
undef; |
46
|
1
|
|
|
1
|
|
270
|
} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |