3 use vars qw($Is_W32 $Is_OS2 $Is_Cygwin $Is_NetWare $Needs_Write $Verbose
5 use Config; # Remember, this is running using an existing perl
9 # Common functions needed by the regen scripts
11 $Is_W32 = $^O eq 'MSWin32';
12 $Is_OS2 = $^O eq 'os2';
13 $Is_Cygwin = $^O eq 'cygwin';
14 $Is_NetWare = $Config{osname} eq 'NetWare';
19 $Needs_Write = $Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare;
22 @ARGV = grep { not($_ eq '-q' and $Verbose = -1) }
23 grep { not($_ eq '-v' and $Verbose = 1) } @ARGV;
26 print STDOUT "Changed: @Changed\n" if @Changed;
34 foreach $name (@names) {
36 chmod 0777, $name if $Needs_Write;
37 ( CORE::unlink($name) and ++$cnt
38 or warn "Couldn't unlink $name: $!\n" );
43 sub safer_rename_silent {
46 # Some dosish systems can't rename over an existing file:
48 chmod 0600, $from if $Needs_Write;
52 sub rename_if_different {
55 if (compare($from, $to) == 0) {
56 warn "no changes between '$from' & '$to'\n" if $Verbose > 0;
60 warn "changed '$from' to '$to'\n" if $Verbose > 0;
61 push @Changed, $to unless $Verbose < 0;
62 safer_rename_silent($from, $to) or die "renaming $from to $to: $!";
65 # Saf*er*, but not totally safe. And assumes always open for output.
69 open $fh, ">$name" or die "Can't create $name: $!";
70 *{$fh}->{SCALAR} = $name;
77 close $fh or die 'Error closing ' . *{$fh}->{SCALAR} . ": $!";