#!/usr/bin/perl -w

use strict;

open(FH, $ARGV[0]);
open(OFH_ONE, "> ".$ARGV[1]);
open(OFH_TWO, "> ".$ARGV[2]);

my $line;
my $alt = 0;

my $header = <FH>;
printf(OFH_ONE $header);
printf(OFH_TWO $header);

while ( $line = <FH> ) {

	if ( $line =~ /^-----\ Begin chunk\ -----$/ ) {
		$alt = 1 - $alt;
	}

	if ( $alt == 0 ) {
		print(OFH_ONE $line);
	} elsif ( $alt == 1 ) {
		print(OFH_TWO $line);
	} else {
		printf("Unhandled: '%s'\n", chomp($line));
	}

}
