Howdy!

I am attempting to import some mailing list archives into lyris format using
a Perl script. I have all of the script working, except for the importing of
the dates.  For some reason, the date field does not import correctly.

Below is the data that I am trying to import and the script used.

Any help or advice would be GREATLY appreciated!!

Thank you!
Andy Schwarz

The e-mail headers look like:

Date:         Mon, 31 Jan 2000 19:09:12 -0600
Reply-To:     Bob Jones <[EMAIL PROTECTED]>
Sender:       ISWORLD Information Systems World
Network<[EMAIL PROTECTED]>
From:         Bob Jones <[EMAIL PROTECTED]>
Subject:      AMCIS 2000 Minitrack

The Perl script:

# find the date line
$DatePos = index($ThisMessage, "Date: ");
$EndDatePos = index($ThisMessage, "\n", $DatePos);

# extract the date line from the header
if ($DatePos > 0) {
   $Date = &Trim(substr($ThisMessage, $DatePos + 6, $EndDatePos - $DatePos -
6));
   $Date = lc($Date);

# parse mail date format
$Date =~ /([0-9]+[0-9]?)
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)((1?9?([8-9]+[0-9]+))|(2?0?
([0-9]+[0-9]+)))/;
$Day = $1;
$Month = $months{$2};
$Year = $3;
$NewDate = $Month.'/'.$Day.'/'.$Year;
$StdDate = &UnformatDate($NewDate);
#print "Day: $Day  Month: $Month  Year: $Year  $NewDate\n";
if ($Month < 1) {
    print "Unable to parse date: $Date\n";
    <STDIN>;
}
else {
    $ThisAttribs{'Created'} = $StdDate;
}

sub UnformatDate {
    my $InDate = $_[0];
    if ($InDate =~ /(.*?)\/(.*?)\/(.*)/) {
        my $tmpYear = "0019".$3;
        my $tmpMonth = "00".$1;
        my $tmpDay = "00".$2;
        my $ReturnDate = substr($tmpYear, length($tmpYear) -
4).substr($tmpMonth, length($tmpMonth) - 2).substr($tmpDay,
length($tmpDay) - 2);
        return $ReturnDate;
    }
    return;
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to