#!/usr/bin/perl -w

use strict;

my ($name)=@ARGV;

my $num=$ENV{'FILENO'};

open NUM,">splits/$name/lastnum";
print NUM "$num\n";
close NUM;


my $from=<STDIN>;

my ($month,$year)=($from=~/^From\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\d+)/);

print "$name: $num $month $year\n";

open DATA,">>splits/$name/$year-$month";
print DATA $from;
while(<STDIN>) {
  print DATA;
}
close DATA;

