| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Slurper::Shortcuts; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2021-08-02'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
96626
|
use strict 'subs', 'vars'; |
|
|
1
|
|
|
|
|
12
|
|
|
|
1
|
|
|
|
|
39
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
14
|
|
|
|
1
|
|
|
|
|
35
|
|
|
8
|
1
|
|
|
1
|
|
5
|
no warnings 'once'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
9
|
1
|
|
|
1
|
|
16
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
93
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
9
|
use File::Slurper (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
252
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
15
|
|
|
|
|
|
|
modify_text |
|
16
|
|
|
|
|
|
|
modify_binary |
|
17
|
|
|
|
|
|
|
replace_text |
|
18
|
|
|
|
|
|
|
replace_binary |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub modify_text { |
|
22
|
1
|
|
|
1
|
1
|
3145
|
my ($filename, $code, $encoding, $crlf) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
5
|
local $_ = File::Slurper::read_text($filename, $encoding, $crlf); |
|
25
|
1
|
|
|
|
|
111
|
my $orig = $_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
4
|
my $res = $code->($_); |
|
28
|
1
|
50
|
|
|
|
14
|
croak "replace_text(): Code does not return true" unless $res; |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
4
|
return if $orig eq $_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
7
|
File::Slurper::write_text($filename, $_, $encoding, $crlf); |
|
33
|
1
|
|
|
|
|
213
|
$orig; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub modify_binary { |
|
37
|
0
|
|
|
0
|
1
|
|
return modify_text(@_[0,1], 'latin-1'); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# old names, deprecated and will be removed in the future |
|
41
|
|
|
|
|
|
|
*replace_text = \&modify_text; |
|
42
|
|
|
|
|
|
|
*replace_binary = \&modify_binary; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
# ABSTRACT: Some convenience additions for File::Slurper |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |