3 use vars qw($Is_W32 $Is_OS2 $Is_Cygwin $Is_NetWare $Needs_Write $Verbose);
4 use Config; # Remember, this is running using an existing perl
8 # Common functions needed by the regen scripts
10 $Is_W32 = $^O eq 'MSWin32';
11 $Is_OS2 = $^O eq 'os2';
12 $Is_Cygwin = $^O eq 'cygwin';
13 $Is_NetWare = $Config{osname} eq 'NetWare';
18 $Needs_Write = $Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare;
20 @ARGV = grep { not($_ eq '-v' and $Verbose = 1) } @ARGV;
27 foreach $name (@names) {
29 chmod 0777, $name if $Needs_Write;
30 ( CORE::unlink($name) and ++$cnt
31 or warn "Couldn't unlink $name: $!\n" );
36 sub safer_rename_silent {
39 # Some dosish systems can't rename over an existing file:
41 chmod 0600, $from if $Needs_Write;
45 sub rename_if_different {
48 if (compare($from, $to) == 0) {
49 warn "no changes between '$from' & '$to'\n" if $Verbose;
53 warn "changed '$from' to '$to'\n";
54 safer_rename_silent($from, $to) or die "renaming $from to $to: $!";
57 # Saf*er*, but not totally safe. And assumes always open for output.
61 open $fh, ">$name" or die "Can't create $name: $!";
62 *{$fh}->{SCALAR} = $name;
69 close $fh or die 'Error closing ' . *{$fh}->{SCALAR} . ": $!";