5 use Carp qw/carp confess/;
10 my $dir = $1 if $file =~ s{^.+/[^/]+}{};
11 File::Path::mkpath $dir unless -e $dir;
15 my ( $file, $content ) = @_;
19 write_file $file, $content;
21 carp "append created $size bytes in $file";
25 my $on_disk = read_file $file;
27 my $relaxed_content =~ s{\s+}{\\s+}gs;
29 if ( $on_disk !~ m{$relaxed_content} ) {
31 # $content =~ s{^[\n\r]+}{\n}s;
32 # $content =~ s{[\n\r]*$}{\n}s;
34 open($fh, '>>', $file);
38 my $size = length($content);
40 carp "append $size bytes to $file";
47 my ( $file, $from, $to ) = @_;
49 my $content = read_file $file;
50 if ( $content =~ s{$from}{$to}s ) {
51 write_file $file, $content;
52 carp "change $file $from => $to";
54 } elsif ( $content !~ m{$to}s ) {
55 confess "can't find $from to change into $to in $file";
60 my ( $file, $content ) = @_;
62 write_file $file, $content;