summaryrefslogtreecommitdiffstats
path: root/lib/MDK/Common/File.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-10-07 16:05:37 +0000
committerThierry Vignaud <tv@mandriva.org>2009-10-07 16:05:37 +0000
commit6d0c7a137813b33cb4e658502153f7c31f8f80e7 (patch)
treebad1b3d473f9b44e962c38acb0e015c03fdb68d7 /lib/MDK/Common/File.pm
parent48644a537553d6d6afde14ebd03c5d4742d5e7b4 (diff)
downloadperl-MDK-Common-6d0c7a137813b33cb4e658502153f7c31f8f80e7.tar
perl-MDK-Common-6d0c7a137813b33cb4e658502153f7c31f8f80e7.tar.gz
perl-MDK-Common-6d0c7a137813b33cb4e658502153f7c31f8f80e7.tar.bz2
perl-MDK-Common-6d0c7a137813b33cb4e658502153f7c31f8f80e7.tar.xz
perl-MDK-Common-6d0c7a137813b33cb4e658502153f7c31f8f80e7.zip
(substInFile) ensure we kept old file as file.bak until we wrote new file
Diffstat (limited to 'lib/MDK/Common/File.pm')
-rw-r--r--lib/MDK/Common/File.pm3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/MDK/Common/File.pm b/lib/MDK/Common/File.pm
index 812d74f..71fe71c 100644
--- a/lib/MDK/Common/File.pm
+++ b/lib/MDK/Common/File.pm
@@ -282,13 +282,14 @@ sub substInFile(&@) {
}
if (-s $file) {
local @ARGV = $file;
- local $^I = '';
+ local $^I = '.bak';
local $_;
while (<>) {
$_ .= "\n" if eof && !/\n/;
&$f($_);
print;
}
+ unlink "$file$^I"; # remove old backup now that we'have closed new file
} else {
local *F; my $old = select F; # that way eof return true
local $_ = '';