#!/sw/bin/perl -w
use strict;

# By: Ventz Petkov
# Date: 8-10-05
# mail2ipod.pl converts an mbox to ipod notes

if (@ARGV != 2) {
    print "\t\tUsage: ./mail2ipod.pl mbox_file name_of_ipod\n";
    print "\t\tEx: ./mail2ipdd.pl ventz_mail Ventz\n"; exit();
}

my ($line, $flag);
$flag = "false";

open(FP, "$ARGV[0]");
while ($line = <FP>) {
    if ($flag eq "true") {
        print $line;
        if($line =~ /^From .*@/) {
            $flag = "false";
        }
    }
    if($line =~ /^From:/) { print $line; }
    if($line =~ /^Cc:/) { print $line; }
    if($line =~ /^Subject:/) { print $line; }
    if($line =~ /^X-UID:/) { $flag = "true"; }
}
close(FP);
