#! /usr/local/bin/perl
# 
# fixit creates a new database called newreal2alias containing the
# contents of the old data base except for the record corresponding 
# to <alias>. This was necessary because of a bug in either dbm
# or perl which failed to delete entries in the database if the key
# was over 1024 characters long. Please don't ask how I managed to
# create a key over 1024 characters long. You should never need to
# use this, but it's here if you do. PLEASE DON'T DO THIS WHEN
# UNSPOOL IS RUNNING. After you run this, you can delete the old
# real2alias db and rename (NOT copy) newreal2alias.{dir,pag} to 
# real2alias.{dir,pag}.
#
# Usage: fixit <target-alias>
#
if ( $#ARGV != 0 ) {
	print STDERR "Usage: fixit <alias>\n";
	exit(1);
}
$target_alias = $ARGV[0];
dbmopen(r2a,"/usr/personals/real2alias",0600) 
	|| die "$0: can't dbmopen real2alias: $!\n";
dbmopen(newr2a,"/usr/personals/newreal2alias",0600) 
	|| die "$0: can't dbmopen newreal2alias: $!\n";
while (($key,$value) = each %r2a) {
	if ( "$value" ne "$target_alias" ) {
		$newr2a{$key} = $value;
		print $key," = ",$value, "\n";
	}
}
dbmclose(r2a);
dbmclose(newr2a);
exit(0);
