line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
1
|
|
|
1
|
|
459
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package filename v0.20.008; |
6
|
|
|
|
|
|
|
# ABSTRACT: Perl module to load files at compile-time, without BEGIN blocks. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp 1.50 (); |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
363
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $error = sub { }; # Private sub |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Modified version of the code as specified in `perldoc -f require` |
15
|
|
|
|
|
|
|
*import = \&require; |
16
|
|
|
|
|
|
|
sub require { |
17
|
18
|
50
|
33
|
18
|
1
|
258822
|
eval { $_[0]->isa(__PACKAGE__) } && shift |
|
18
|
|
|
|
|
139
|
|
18
|
|
|
|
|
|
|
|| Carp::croak( $_[0], " is not a ", __PACKAGE__ ); |
19
|
18
|
100
|
|
|
|
49
|
my $filename = @_ ? shift : $_; |
20
|
18
|
50
|
|
|
|
32
|
Carp::croak("Null filename used") unless length($filename); |
21
|
|
|
|
|
|
|
|
22
|
18
|
100
|
|
|
|
59
|
return $INC{$filename} if ( exists $INC{$filename} ); |
23
|
|
|
|
|
|
|
|
24
|
16
|
100
|
|
|
|
51
|
if ( $filename =~ m!\A/! ) { |
25
|
8
|
50
|
33
|
|
|
83
|
goto NOT_INC if $^V < v5.17.0 && !-r $filename; |
26
|
8
|
|
100
|
|
|
626
|
return do($filename) || $error->($filename); |
27
|
|
|
|
|
|
|
} |
28
|
8
|
|
|
|
|
14
|
foreach my $prefix (@INC) { |
29
|
8
|
50
|
|
|
|
151
|
next unless -f ( my $fullpath = "$prefix/$filename" ); |
30
|
8
|
50
|
33
|
|
|
93
|
next if $^V < v5.17.0 && !-r _; |
31
|
8
|
|
|
|
|
766
|
my $result = do $fullpath; |
32
|
8
|
|
|
|
|
68
|
$INC{$filename} = delete $INC{$fullpath}; |
33
|
8
|
|
100
|
|
|
69
|
return $result || $error->( $filename => $fullpath ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
NOT_INC: |
36
|
0
|
|
|
|
|
|
Carp::croak("Can't locate $filename in \@INC (\@INC contains: @INC)"); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Private sub |
40
|
|
|
|
|
|
|
$error = sub { |
41
|
|
|
|
|
|
|
my $filename = @_ ? shift : $_; |
42
|
|
|
|
|
|
|
my $fullpath = @_ ? shift : $filename; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$INC{$filename} = undef; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$@ && Carp::croak( $@, "Compilation failed in require" ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$! && Carp::croak( |
49
|
|
|
|
|
|
|
"Can't locate $filename: ", |
50
|
|
|
|
|
|
|
$^V >= v5.21.0 ? "$fullpath: " : (), |
51
|
|
|
|
|
|
|
"$!" |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
delete $INC{$filename}; |
55
|
|
|
|
|
|
|
Carp::croak( $filename, " did not return a true value" ); |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |