##################################################################
#
# Clean-up .aip files generated by aipdata.xls
#
##################################################################
foreach (<*.aip>)
{
	$file = $_;
	$old = $file;
	$new = "$file.tmp.$$";
	$bak = "$file.bak";

	open(OLD, "< $old") or die "can't open $old: $!";
	open(NEW, "> $new") or die "can't open $new: $!";

	while (<OLD>)
	{
		s/"##,#//gs;
		s/##,#"//gs;
		s/""/"/gs;
		(print NEW $_) or die "can't write to $new: $!";
	}

	close(OLD) or die "can't close $old: $!";
	close(NEW) or die "can't close $new: $!";

	rename($old, $bak) or die "can't rename $old to $bak: $!";
	rename($new, $old) or die "can't rename $new to $old: $!";
}

