3 use vars qw($Needs_Write $Verbose @Changed);
7 # Common functions needed by the regen scripts
9 $Needs_Write = $^O eq 'cygwin' || $^O eq 'os2' || $^O eq 'MSWin32';
12 @ARGV = grep { not($_ eq '-q' and $Verbose = -1) }
13 grep { not($_ eq '-v' and $Verbose = 1) } @ARGV;
16 print STDOUT "Changed: @Changed\n" if @Changed;
24 foreach $name (@names) {
26 chmod 0777, $name if $Needs_Write;
27 ( CORE::unlink($name) and ++$cnt
28 or warn "Couldn't unlink $name: $!\n" );
33 sub safer_rename_silent {
36 # Some dosish systems can't rename over an existing file:
38 chmod 0600, $from if $Needs_Write;
42 sub rename_if_different {
45 if (compare($from, $to) == 0) {
46 warn "no changes between '$from' & '$to'\n" if $Verbose > 0;
50 warn "changed '$from' to '$to'\n" if $Verbose > 0;
51 push @Changed, $to unless $Verbose < 0;
52 safer_rename_silent($from, $to) or die "renaming $from to $to: $!";
55 # Saf*er*, but not totally safe. And assumes always open for output.
59 open $fh, ">$name" or die "Can't create $name: $!";
60 *{$fh}->{SCALAR} = $name;
67 close $fh or die 'Error closing ' . *{$fh}->{SCALAR} . ": $!";