aboutsummaryrefslogtreecommitdiff
path: root/scripts/alternate-stream
blob: ea8c8750025125d71f97447a80082de95b33eb0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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));
	}

}