N
Nathan
-----------
the problem
-----------
I believe the "from" headers of today's email are not the same the module
was originally written for.
the test cases for Mail::Thread show this in the '^From ' field:
----
grep
----
[user@host]$ grep '^From ' file.email
From (e-mail address removed) Tue Jan 7 12:09:16 2003
From (e-mail address removed) Tue Jan 7 12:57:03 2003
From (e-mail address removed) Tue Jan 7 13:27:08 2003
From (e-mail address removed) Tue Jan 7 13:52:02 2003
From (e-mail address removed) Tue Jan 7 14:57:20 2003
From (e-mail address removed) Tue Jan 7 15:44:22 2003
From (e-mail address removed) Tue Jan 7 16:21:03 2003
From (e-mail address removed) Tue Jan 7 16:38:00 2003
From (e-mail address removed) Tue Jan 7 20:34:20 2003
From (e-mail address removed) Wed Jan 8 00:19:39 2003
-------------------
todays from headers
-------------------
From: "Nathan" <[email protected]>
----------------------
trying to fix the code
----------------------
I noted that there is the line if(/^From / ...)
I figured I might be able to change it to fit the newer "From" headers,
after changing it to if(/^From: / ...) the script fails with the error
message:
attempt to thread message with no id at
/usr/lib/perl5/site_perl/5.8.4/Mail/Thread.pm line 46, <FH> line 1061.
I've been working on this for a few days and really don't know whats
screwing up. Could anybody provide me with some insite on this module, or
perhaps working examples with a mail from today?
Thanks in Advance,
--Nathan
(Please post replys to this group)
--------
the code
--------
#!/usr/bin/perl -w
use strict;
use warnings;
use Mail::Internet;
package Email::Abstract::Mail;
use base 'Email::Abstract::MailInternet';
package Mail;
use base 'Mail::Internet';
require Mail::Thread;
my $threader = new Mail::Thread( slurp_messages('file.email') );
$threader->thread;
dump_em($_,0) for $threader->rootset;
sub dump_em {
my ($self, $level) = @_;
#debug (' \\-> ' x $level);
if ($self->message) {
print $self->message->head->get("Subject") , "\n";
} else {
print "[ Message $self not available ]\n";
}
dump_em($self->child, $level+1) if $self->child;
dump_em($self->next, $level) if $self->next;
}
sub slurp_messages {
my $mbox = shift;
open FH, $mbox or return;
my @messages;
my @lines;
while (<FH>) {
if (/^From / && @lines) {
my $mail = Mail->new(\@lines);
push @messages, $mail;
@lines = ();
}
push @lines, $_;
}
return @messages, Mail->new(\@lines);
}
the problem
-----------
I believe the "from" headers of today's email are not the same the module
was originally written for.
the test cases for Mail::Thread show this in the '^From ' field:
----
grep
----
[user@host]$ grep '^From ' file.email
From (e-mail address removed) Tue Jan 7 12:09:16 2003
From (e-mail address removed) Tue Jan 7 12:57:03 2003
From (e-mail address removed) Tue Jan 7 13:27:08 2003
From (e-mail address removed) Tue Jan 7 13:52:02 2003
From (e-mail address removed) Tue Jan 7 14:57:20 2003
From (e-mail address removed) Tue Jan 7 15:44:22 2003
From (e-mail address removed) Tue Jan 7 16:21:03 2003
From (e-mail address removed) Tue Jan 7 16:38:00 2003
From (e-mail address removed) Tue Jan 7 20:34:20 2003
From (e-mail address removed) Wed Jan 8 00:19:39 2003
-------------------
todays from headers
-------------------
From: "Nathan" <[email protected]>
----------------------
trying to fix the code
----------------------
I noted that there is the line if(/^From / ...)
I figured I might be able to change it to fit the newer "From" headers,
after changing it to if(/^From: / ...) the script fails with the error
message:
attempt to thread message with no id at
/usr/lib/perl5/site_perl/5.8.4/Mail/Thread.pm line 46, <FH> line 1061.
I've been working on this for a few days and really don't know whats
screwing up. Could anybody provide me with some insite on this module, or
perhaps working examples with a mail from today?
Thanks in Advance,
--Nathan
(Please post replys to this group)
--------
the code
--------
#!/usr/bin/perl -w
use strict;
use warnings;
use Mail::Internet;
package Email::Abstract::Mail;
use base 'Email::Abstract::MailInternet';
package Mail;
use base 'Mail::Internet';
require Mail::Thread;
my $threader = new Mail::Thread( slurp_messages('file.email') );
$threader->thread;
dump_em($_,0) for $threader->rootset;
sub dump_em {
my ($self, $level) = @_;
#debug (' \\-> ' x $level);
if ($self->message) {
print $self->message->head->get("Subject") , "\n";
} else {
print "[ Message $self not available ]\n";
}
dump_em($self->child, $level+1) if $self->child;
dump_em($self->next, $level) if $self->next;
}
sub slurp_messages {
my $mbox = shift;
open FH, $mbox or return;
my @messages;
my @lines;
while (<FH>) {
if (/^From / && @lines) {
my $mail = Mail->new(\@lines);
push @messages, $mail;
@lines = ();
}
push @lines, $_;
}
return @messages, Mail->new(\@lines);
}