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

In reply to Feeding Mail::Message ... by holo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.