| 1 | package File::Update; | ||||||||||||||||||||||||||||
| 2 | 2 | $File::Update::VERSION = '0.0.3'; | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | our @EXPORT_OK = (qw(modify_on_change write_on_change write_on_change_no_utf8)); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub write_on_change | ||||||||||||||||||||||||||||
| 11 | { | ||||||||||||||||||||||||||||
| 12 | 3 | ▶ | my ( $io, $text_ref ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write_on_change: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | if ( ( !-e $io ) or ( $io->slurp_utf8() ne $$text_ref ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not -e $io or $io->slurp_utf8 ne $$text_ref
MC/DC100%2/2
not -e $io or $io->slurp_utf8 ne $$text_ref
not -e $io
$io->slurp_utf8 ne $$text_ref
Truth table100%3/3
not(A) or B
A= not -e $ioB= $io->slurp_utf8 ne $$text_ref
| |||||||||||||||||||||||||||||
| 15 | { | ||||||||||||||||||||||||||||
| 16 | 2 | $io->spew_utf8($$text_ref); | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | return; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub modify_on_change | ||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | my ( $io, $sub_ref ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
modify_on_change: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | my $text = $io->slurp_utf8(); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | if ( $sub_ref->( \$text ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 1 | $io->spew_utf8($text); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | return; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub write_on_change_no_utf8 | ||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ( $io, $text_ref ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write_on_change_no_utf8: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ( ( !-e $io ) or ( $io->slurp() ne $$text_ref ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -e $io or $io->slurp ne $$text_ref
MC/DC0%0/2
not -e $io or $io->slurp ne $$text_ref
not -e $io
$io->slurp ne $$text_ref
Truth table0%0/3
not(A) or B
A= not -e $ioB= $io->slurp ne $$text_ref
| |||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||
| 42 | 0 | $io->spew($$text_ref); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | return; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | 1; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||