holo has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I'm having a tiny problem with Mail::Message. I'm trying to feed an email to a perl script (STDIN) that is supposed to put it in a Mail::Message object to be able to manipulate it. After looking at Mail::Message and friends, I came up with the following snippet:
use Mail::Message; my $s = "Subject: hello\n\n1\n2\n"; my $msg1 = Mail::Message->read(\$s);
That is supoposed to construct an object from the given scalar ref and throw it in $msg1 but, when I run it, I get the following:
Can't use string ("Mail::Message") as a HASH ref while "strict refs" i +n use at usr/share/perl5/Mail/Message.pm line 853.
After further investigation, I found the following code in a the module's test suite:
my $scalar = "Subject: hello world\n\nbody1\nbody2\n"; my $msg2 = Mail::Message->read(\$scalar); ok(defined $msg2); is(ref $msg2, 'Mail::Message'); ok(defined $msg2->head); isa_ok($msg2->head, 'Mail::Message::Head');
I installed Mail::Message using CPAN.pm and all the tests passed ... leading me to think that I'm missing something ?
Can someone enlighten me ?
10x
-- holo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Feeding Mail::Message ...
by PodMaster (Abbot) on Jan 07, 2003 at 05:01 UTC | |
by holo (Monk) on Jan 07, 2003 at 07:47 UTC |