summaryrefslogtreecommitdiff
path: root/regen/regen_lib.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-23 09:39:21 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-23 09:39:21 +0000
commit396ce246b9969d83ec11500def9604b58fb4c726 (patch)
treef734958364f9fa7ee848980d1455b4b2269d8056 /regen/regen_lib.pl
parentbb5cff7d658d1934f2c79f668c3b916bd9abbcbb (diff)
downloadperl-396ce246b9969d83ec11500def9604b58fb4c726.tar.gz
In regen_lib.pl, when opening, first unlink a previous file of that name.
Previously regcomp.pl had an explicit unlink for the file it creates, but none of the other regen/*.pl scripts did. Also, remove commented out code relating to unlink.
Diffstat (limited to 'regen/regen_lib.pl')
-rw-r--r--regen/regen_lib.pl3
1 files changed, 3 insertions, 0 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl
index b4d9f86c1e..880a9754d5 100644
--- a/regen/regen_lib.pl
+++ b/regen/regen_lib.pl
@@ -63,6 +63,9 @@ sub rename_if_different {
# Saf*er*, but not totally safe. And assumes always open for output.
sub safer_open {
my $name = shift;
+ if (-f $name) {
+ unlink $name or die "$name exists but can't unlink: $!";
+ }
my $fh = gensym;
open $fh, ">$name" or die "Can't create $name: $!";
*{$fh}->{name} = $name;