line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Slurper::Shortcuts; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-10-06'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
71492
|
use strict 'subs', 'vars'; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
4
|
no warnings 'once'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use File::Slurper (); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
18
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use Exporter qw(import); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
185
|
|
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
|
2433
|
my ($filename, $code, $encoding, $crlf) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
5
|
local $_ = File::Slurper::read_text($filename, $encoding, $crlf); |
25
|
1
|
|
|
|
|
85
|
my $orig = $_; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
3
|
my $res = $code->($_); |
28
|
1
|
50
|
|
|
|
10
|
croak "replace_text(): Code does not return true" unless $res; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
4
|
return if $orig eq $_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
6
|
File::Slurper::write_text($filename, $_, $encoding, $crlf); |
33
|
1
|
|
|
|
|
165
|
$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__ |