#!/usr/bin/perl
#
# Combine the two next-chunk lists on the ID value
# Stay within NextChunkHeader format
my ($start, $end) = @ARGV;
my %List = ();
open(BF, "<$start");
while(<BF>)
{
	chomp;
	my $ID = (split)[2];
	$List{$ID}=$_;
};

open(BF, "<$start");
while(<BF>)
{
	chomp;
	my $ID = (split)[2];
	$List{$ID} = "NULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL" unless exists($List{$ID});
	$List{$ID}.="\t$_";
};

foreach $ID (sort keys(%List))
{
	my @item_list = split(/\t/, $List{$ID});
	$List{$ID} .= "\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL\tNULL" 
	       unless scalar(@item_list) > 9;
	print $List{$ID}, "\n";
}
