line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Update; |
2
|
|
|
|
|
|
|
$File::Update::VERSION = '0.2.0'; |
3
|
1
|
|
|
1
|
|
82906
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
451
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
304
|
|
|
1
|
|
|
|
|
5
|
|
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
|
1028943
|
my ( $io, $text_ref ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
3
|
100
|
100
|
|
|
32
|
if ( ( !-e $io ) or ( $io->slurp_utf8() ne $$text_ref ) ) |
17
|
|
|
|
|
|
|
{ |
18
|
2
|
|
|
|
|
220
|
$io->spew_utf8($$text_ref); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
2538
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub modify_on_change |
25
|
|
|
|
|
|
|
{ |
26
|
1
|
|
|
1
|
1
|
782
|
my ( $io, $sub_ref ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
5
|
my $text = $io->slurp_utf8(); |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
160
|
if ( $sub_ref->( \$text ) ) |
31
|
|
|
|
|
|
|
{ |
32
|
1
|
|
|
|
|
22
|
$io->spew_utf8($text); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
481
|
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
|
977
|
my ( $io, $text_ref ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
33
|
|
|
4
|
if ( ( !-e $io ) or ( $io->slurp_raw() ne $$text_ref ) ) |
55
|
|
|
|
|
|
|
{ |
56
|
1
|
|
|
|
|
33
|
$io->spew_raw($$text_ref); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
377
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |