#! /usr/local/bin/perl -w
my $summary = shift;
my $runs = shift;

open(S,"$summary") || die "Cannot open summary $summary\n";
while (<S>) {
    chomp;
    unless ($_ =~ /^#/) {
        ($stage_product,$size_in_gb) = split /\s+/;
        ($stage,$product) = split /_/, $stage_product;

        $size{$stage}{$product} = $size_in_gb;
    }
}
close(S);
close(S);

open(C,"$runs") || die "Cannot find runs $runs\n";
while(<C>) {
    chomp;
    unless ($_ =~ /^#/) {
        ($stage,$state,$N) = split /\s/;
        if ($state eq '') {
            $state = 'NULL';
        }
        $count{$stage}{$state} = $N;
    }
}
close(C);

foreach $stage (keys (%size)) {
    foreach $product (keys (%{ $size{$stage} })) {
        foreach $state (keys (%{ $count{$stage} })) {
	    print "$stage $product $state\n";
	}
    }
}

