line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Slurp::Shortcuts; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
119440
|
use 5.010001; # yes, i know, i'm spoilt. |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
6
|
2
|
|
|
2
|
|
1692
|
use experimental 'smartmatch'; |
|
2
|
|
|
|
|
1732
|
|
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1997
|
use File::Slurp qw(); |
|
2
|
|
|
|
|
29402
|
|
|
2
|
|
|
|
|
131
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @my_replace = qw(read_file slurp); |
11
|
|
|
|
|
|
|
our @my_exportok = qw(read_file_c slurp_c |
12
|
|
|
|
|
|
|
read_file_cq slurp_cq |
13
|
|
|
|
|
|
|
read_file_q slurp_q); |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
25
|
use base qw(Exporter); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
323
|
|
16
|
|
|
|
|
|
|
our %EXPORT_TAGS = %File::Slurp::EXPORT_TAGS; |
17
|
|
|
|
|
|
|
our @EXPORT = @File::Slurp::EXPORT; |
18
|
|
|
|
|
|
|
our @EXPORT_OK = (@File::Slurp::EXPORT_OK, @my_exportok); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
887
|
|
23
|
|
|
|
|
|
|
# import all of File::Slurp, except our own replacement |
24
|
|
|
|
|
|
|
for (@File::Slurp::EXPORT, @File::Slurp::EXPORT_OK) { |
25
|
|
|
|
|
|
|
*{$_} = \&{"File::Slurp::".$_} unless $_ ~~ @my_replace; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub read_file { |
29
|
13
|
|
|
13
|
0
|
919
|
my ($path, %opts) = @_; |
30
|
13
|
|
|
|
|
23
|
my $wa = wantarray; |
31
|
|
|
|
|
|
|
|
32
|
13
|
|
|
|
|
20
|
my $res; |
33
|
|
|
|
|
|
|
my @res; |
34
|
13
|
50
|
|
|
|
34
|
if ($wa) { |
35
|
0
|
|
|
|
|
0
|
@res = File::Slurp::read_file($path, %opts); |
36
|
0
|
0
|
|
|
|
0
|
if ($opts{chomp}) { chomp for @res } |
|
0
|
|
|
|
|
0
|
|
37
|
0
|
|
|
|
|
0
|
return @res; |
38
|
|
|
|
|
|
|
} else { |
39
|
13
|
|
|
|
|
55
|
$res = File::Slurp::read_file($path, %opts); |
40
|
11
|
100
|
100
|
|
|
1744
|
if ($res && $opts{chomp}) { chomp $res } |
|
4
|
|
|
|
|
12
|
|
41
|
11
|
|
|
|
|
138
|
return $res; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
*slurp = \&read_file; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub read_file_cq { |
47
|
4
|
|
|
4
|
1
|
1056
|
my ($path, %opts) = @_; |
48
|
4
|
|
50
|
|
|
31
|
$opts{err_mode} //= 'quiet'; |
49
|
4
|
|
50
|
|
|
18
|
$opts{chomp} //= 1; |
50
|
4
|
|
|
|
|
17
|
read_file($path, %opts); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
*slurp_cq = \&read_file_cq; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub read_file_c { |
55
|
4
|
|
|
4
|
1
|
1972
|
my ($path, %opts) = @_; |
56
|
4
|
|
50
|
|
|
25
|
$opts{chomp} //= 1; |
57
|
4
|
|
|
|
|
14
|
read_file($path, %opts); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
*slurp_c = \&read_file_c; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub read_file_q { |
62
|
4
|
|
|
4
|
1
|
1176
|
my ($path, %opts) = @_; |
63
|
4
|
|
50
|
|
|
23
|
$opts{err_mode} //= 'quiet'; |
64
|
4
|
|
|
|
|
13
|
read_file($path, %opts); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
*slurp_q = \&read_file_q; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
# ABSTRACT: Several shortcut functions for File::Slurp |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |