#!/usr/local/bin/perl

$hdr = pop(@ARGV);

while (<>) {
    if (/^From /) {
	close(FILE);
	$fname = sprintf("%s/%04d", $hdr, $fnum++);
	open(FILE, ">$fname") || die("open(\">$fname\"): $!");
    }

    print FILE $_;
}

print "DONE!\n";
