help with mime head

Discussion in 'Perl Misc' started by jcharth@hotmail.com, Jan 27, 2007.

  1. Guest

    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 |");
     
    , Jan 27, 2007
    #1
    1. Advertising

  2. Guest

    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));



    On Jan 27, 10:31 am, Michele Dondi <> wrote:
    > On 27 Jan 2007 06:48:27 -0800, wrote:
    >
    > >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,
     
    , Jan 28, 2007
    #2
    1. Advertising

  3. Guest

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

    On Jan 28, 1:04 pm, Michele Dondi <> wrote:
    > On 28 Jan 2007 09:12:58 -0800, wrote:
    >
    > >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 <> 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,
     
    , Jan 29, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian W
    Replies:
    10
    Views:
    823
    Brian W
    Jul 2, 2003
  2. showme

    PHP and ASP.NET go HEAD to HEAD

    showme, Jul 8, 2004, in forum: ASP .Net
    Replies:
    13
    Views:
    784
    Sherif ElMetainy
    Jul 10, 2004
  3. Karl
    Replies:
    0
    Views:
    434
  4. Jiho Han

    Write into <HEAD></HEAD> section?

    Jiho Han, Jan 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    6
    Views:
    264
    Sam Fields
    Jan 16, 2004
  5. joe

    mime head alternative

    joe, Apr 19, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    83
Loading...

Share This Page