#!/usr/central/bin/perl -swi.bak

use vars qw( $v *ARGVOUT );
use File::Copy;

# We need to change all instances of '-lgdbm' to '-lc -lgdbm'
#
# The original files are kept as .bak is there are changes.
# If there are no changes the original is moved back into place.

$changed = 0;
while (<>) {
   if (s/-lgdbm/-lc -lgdbm/g) {
      $changed = 1;
   }
   print;
   if (eof) {
# Close handles to avoid warnings...
      close ARGV;
      close ARGVOUT;
      move "$ARGV.bak", $ARGV if (not $changed);
      print STDERR "$ARGV done\n" if (defined $v);
      $changed = 0;
   }
}
