#!/bin/perl
$|=1;
$msg = "";
$nr = undef;
$id = undef;

sub save_msg {
    if (defined $nr && $nr < 1529) {
	open(MSG,">squid-dev/$nr") || die("open");
	print MSG $msg;
	close MSG;
	print $nr." ".$id."\n";
    }
    $msg = "";
    $nr = undef;
    $id = undef;
}

while(<>) {
/^From / && do {
    &save_msg;
};
/^X-Mailing-List.*squid-dev.*archive.latest.(\d+)/ && do {
    $nr = $1;
    };
/^Message-ID:.*<(.*)>/ && do {
    $id = $1;
    };
$msg .= $_;
}
&save_msg;

print "\n";
