help with mime head

J

jcharth

Hello I am trygint to get the header of a string. I dont thnk this can
be done with the mime head module but may bet there is a work around.
I am fetching a message to a variable called
$message using LWP, i tried MIME::HEAD->read"$message" and -
from_file("$message) but now luck. May be I need a funtion that
writes the buffer to the tempfolder and returns the name of the temp
fie?


$head = MIME::Head->read(\*STDIN);

### Parse a new header from a file, or a readable pipe:
$testhead = MIME::Head->from_file("/tmp/test.hdr");
$a_b_head = MIME::Head->from_file("cat a.hdr b.hdr |");
 
J

jcharth

I tried using open my $fh but $head->get returns an empty string
everysingle time, if i print $message I see the full message.

open my $fh, '<', \$message or die "D'Oh! $!\n";
my $head = MIME::Head->read($fh);

$myTo = lc($head->get('To',0));



Hello I am trygint to get the header of a string. I dont thnk this can
be done with the mime head module but may bet there is a work around.
I am fetching a message to a variable called
$message using LWP, i tried MIME::HEAD->read"$message" and -The module is MIME::Head, and the above is not syntactically valid
Perl: parens around method calls are mandatory except when the
argument list is empty. Also, not strictly an error, but you don't
need to quote $message. See

perldoc -q quoting

Also, reading M::H's docs I see

: Before reading further, you should see MIME::Tools to make sure that
: you understand where this module fits into the grand scheme of things.
: Go on, do it now. I'll wait.

However, it also says

: ### Parse a new header from a filehandle:
: $head = MIME::Head->read(\*STDIN);
:
: ### Parse a new header from a file, or a readable pipe:
: $testhead = MIME::Head->from_file("/tmp/test.hdr");
: $a_b_head = MIME::Head->from_file("cat a.hdr b.hdr |");

Thus you can open() $message in memory:

open my $fh, '<', \$message or die "D'Oh! $!\n";
my $head = MIME::Head->read($fh);

Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
J

jcharth

Thanks michael, the problem was i was downloading the file using
as_string instead of content in lwp. i had some extra http headers.

I tried using open my $fh but $head->get returns an empty string
everysingle time, if i print $message I see the full message.
open my $fh, '<', \$message or die "D'Oh! $!\n";
my $head = MIME::Head->read($fh);
$myTo = lc($head->get('To',0));Are things different if you save $message to a temporary file and
parse that? I see no reason why they should, but just to be sure...
oh, and I hope your perl is recent enough, but if it is not, I mean if
it doesn't support open()ing scalars in memory, then I suppose it
would just give you an error - either that or try to open a file with
the name of the stringified reference for reading, which is unlikely
to exist and would cause the program to die() anyway. I don't know for
sure because I only have access to fairly recent perls. Other than
this I can only quote myself:

: Also, reading M::H's docs I see
:
: : Before reading further, you should see MIME::Tools to make sure that
: : you understand where this module fits into the grand scheme of things.
: : Go on, do it now. I'll wait.

Did you do so?
On Jan 27, 10:31 am, Michele Dondi <[email protected]> wrote:[snip full quoted content]

*Please* do not top-post. If you don't know what top-posting is, then
google for it. It makes very hard for us to follow the discussion
properly.

Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top