From 6d0c7a137813b33cb4e658502153f7c31f8f80e7 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 7 Oct 2009 16:05:37 +0000 Subject: (substInFile) ensure we kept old file as file.bak until we wrote new file --- lib/MDK/Common/File.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') 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 $_ = ''; -- cgit v1.2.1