On Friday, May 17, 2002, at 05:34 , Andy Schwarz wrote:
[..]
> 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));
[..]

how about a little simpler???

I had to add a line of Junk to even get yours to almost fly

If I remove the line of HeaderStuff Junk it chokes....

but either way why not the simpler

        sub GrotDateFromMsg {
                my ($msg ) = @_;
        my $string = 'bad';

        if ($msg =~ m/Date:\s+([^\n]+)/ ) {
                $string = $1;
        }
        $string;
        }

given your 'message' it will return the thing I think you want
and the print " She Called it's a \$Date :$Date:\n" ; puts your
variable inbetween the colons....

        :Mon, 31 Jan 2000 19:09:12 -0600:       # the ':' are to show size


then from there you can get along to reverse engineering what ever
it is that you want...

ciao
drieux

---

my $ThisMessage =<<EOM;
HeaderStuff Junk
Date:         Mon, 31 Jan 2000 19:09:12 -0600
Reply-To:     Bob Jones
Sender:       ISWORLD Information Systems World
Network<ISWORLD\@LISTSERV.HEANET.IE>
From:         Bob Jones <bjones\@MAIL.COX.SMU.EDU>
Subject:      AMCIS 2000 Minitrack

EOM

print "Start with:\n$ThisMessage\n#-------\n";

my $DatePos = index($ThisMessage, "Date:");
my $EndDatePos = index($ThisMessage, "\n", $DatePos);
my $Date;

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

}
if ($Date) {
        print "$Date\n" ;
}else{
        print "No date for \$Date - it just sit by the phone\n";
}

if ($ThisMessage =~ m/Date:\s+([^\n]+)/ ) {
        $Date = $1;

        if ($Date) {
                print " She Called it's a \$Date :$Date:\n" ;
        }
}


#------------------------
#
sub Trim {
        my ($msg ) = @_;
     my $string = 'bad';
     print "Sub: with :$msg:\n";
     if ($msg =~ m/Date:\s+([^\n]+)/ ) {
        $string = $1;
     }
     $string;
} # end of Trim


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

Reply via email to