This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In regen_lib.pl, when opening, first unlink a previous file of that name.
[perl5.git] / regen / regen_lib.pl
index b4d9f86..880a975 100644 (file)
@@ -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;