line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Update; |
2
|
|
|
|
|
|
|
$File::Update::VERSION = '0.2.1'; |
3
|
1
|
|
|
1
|
|
81271
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
480
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
323
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
9
|
|
|
|
|
|
|
qw(modify_on_change write_on_change write_on_change_raw write_on_change_no_utf8) |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub write_on_change |
13
|
|
|
|
|
|
|
{ |
14
|
3
|
|
|
3
|
1
|
1027949
|
my ( $io, $text_ref ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
3
|
100
|
100
|
|
|
28
|
if ( ( !-e $io ) or ( $io->slurp_utf8() ne $$text_ref ) ) |
17
|
|
|
|
|
|
|
{ |
18
|
2
|
|
|
|
|
221
|
$io->spew_utf8($$text_ref); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
2325
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub modify_on_change |
25
|
|
|
|
|
|
|
{ |
26
|
1
|
|
|
1
|
1
|
775
|
my ( $io, $sub_ref ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
4
|
my $text = $io->slurp_utf8(); |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
158
|
if ( $sub_ref->( \$text ) ) |
31
|
|
|
|
|
|
|
{ |
32
|
1
|
|
|
|
|
21
|
$io->spew_utf8($text); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
418
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub write_on_change_no_utf8 |
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
0
|
1
|
0
|
my ( $io, $text_ref ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
0
|
if ( ( !-e $io ) or ( $io->slurp() ne $$text_ref ) ) |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
0
|
$io->spew($$text_ref); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub write_on_change_raw |
51
|
|
|
|
|
|
|
{ |
52
|
1
|
|
|
1
|
1
|
741
|
my ( $io, $text_ref ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
33
|
|
|
5
|
if ( ( !-e $io ) or ( $io->slurp_raw() ne $$text_ref ) ) |
55
|
|
|
|
|
|
|
{ |
56
|
1
|
|
|
|
|
32
|
$io->spew_raw($$text_ref); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
387
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |