line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Update; |
2
|
|
|
|
|
|
|
$File::Update::VERSION = '0.0.3'; |
3
|
1
|
|
|
1
|
|
75296
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
364
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
254
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(modify_on_change write_on_change write_on_change_no_utf8)); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub write_on_change |
11
|
|
|
|
|
|
|
{ |
12
|
3
|
|
|
3
|
1
|
1022123
|
my ( $io, $text_ref ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
3
|
100
|
100
|
|
|
19
|
if ( ( !-e $io ) or ( $io->slurp_utf8() ne $$text_ref ) ) |
15
|
|
|
|
|
|
|
{ |
16
|
2
|
|
|
|
|
188
|
$io->spew_utf8($$text_ref); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
1990
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub modify_on_change |
23
|
|
|
|
|
|
|
{ |
24
|
1
|
|
|
1
|
1
|
631
|
my ( $io, $sub_ref ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
my $text = $io->slurp_utf8(); |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
148
|
if ( $sub_ref->( \$text ) ) |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
|
|
15
|
$io->spew_utf8($text); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
325
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub write_on_change_no_utf8 |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
0
|
1
|
|
my ( $io, $text_ref ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
0
|
|
|
|
if ( ( !-e $io ) or ( $io->slurp() ne $$text_ref ) ) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
|
$io->spew($$text_ref); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |