/[pxelator]/lib/PXElator/file.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/file.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 437 by dpavlin, Wed Aug 26 09:06:10 2009 UTC revision 438 by dpavlin, Sun Sep 20 16:11:16 2009 UTC
# Line 6  use Carp qw/carp confess/; Line 6  use Carp qw/carp confess/;
6  use File::Path qw//;  use File::Path qw//;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8    
9  my $debug = 1;  my $debug = 0;
10    
11  sub mkpath {  sub mkpath {
12          my $file = shift;          my $file = shift;
# Line 39  sub append { Line 39  sub append {
39  #               $content =~ s{[\n\r]*$}{\n}s;  #               $content =~ s{[\n\r]*$}{\n}s;
40    
41                  if ( $on_disk =~ s{([\s+]exit[\s\d]*)$}{\n$content\n$1}s ) {                  if ( $on_disk =~ s{([\s+]exit[\s\d]*)$}{\n$content\n$1}s ) {
42  #                       warn "# insert $file\n$on_disk";                          warn "# insert $file\n$on_disk" if $debug;
43                          write_file $file, $on_disk;                          write_file $file, $on_disk;
44                  } else {                  } else {
45  #                       warn "# append $file\n$content\n";                          warn "# append $file\n$content\n" if $debug;
46                          open($fh, '>>', $file);                          open($fh, '>>', $file);
47                          print $fh $content;                          print $fh $content;
48                          close($fh);                          close($fh);
49                  }                  }
50    
51                  carp "## append to $file";                  carp "## append to $file" if $debug;
52                  return -s $file;                  return -s $file;
53            } else {
54                    warn "## $file not modified" if $debug;
55          }          }
56  }  }
57    

Legend:
Removed from v.437  
changed lines
  Added in v.438

  ViewVC Help
Powered by ViewVC 1.1.26