#!/usr/bin/perl -w

# Quick and dirty script to combine .soa and .primary files
# into one zone.db file
#
# Ed Negari
# 12-3-2003


$OUTDIR="/home/ed/tmp/new-idt";
$MASK="idt.net.db";

@FILELIST=`find ./ -name .primary`;
chomp @FILELIST;

foreach $LINE (@FILELIST) {
	chomp $LINE;
	#print "LINE = $LINE\n";
	$LINE =~ s/\.primary//g;
	$LINE =~ s/\.//g;
	#print "LINE = $LINE\n";
	@FILE=split( /\//, $LINE );
	@FILE = reverse @FILE;
	#print "FILE = @FILE\n";

	$OUTFILE = $MASK;
	foreach (@FILE) {
		$OUTFILE = $_ . "." . $OUTFILE;
	} #end foreach

	#chop off leading period
	$OUTFILE =~ s/^.//g;

	print "Creating $OUTFILE\n";

	`cat .$LINE.soa > $OUTDIR/$OUTFILE`;
	`cat .$LINE.primary >> $OUTDIR/$OUTFILE`;

	# clear for next iteration
	@FILE="";
	$OUTFILE = "";

} #end foreach
