http://qs1969.pair.com?node_id=60232


in reply to quoted-printable, and ugly code

Lots of items already covered here. But I felt compelled to note that s/^\w+:(.*)$/$1/gs nearly makes me cringe (which is silly because it really isn't "bad" at all). First, s/^\w+://gs gets the point across much better, I think. Second, can't headers have "-" in them so don't you want [-\w]+? Third, I'd strip whitespace after the ":". So:

s/^[-\w]+:\s*//gs

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: quoted-printable, and ugly code
by McD (Chaplain) on Feb 23, 2001 at 00:24 UTC
    Better yet, I think you can get both the quoted-printable decoding you want and the mail header parsing you'd like with use MIME::Parser, part of the MIME-tools package.

    And if what you're doing is tinkering with a Perl-based mail filter, check out Mail::Audit.

    Peace,
    -McD

      MIME::Parser is a real heavyweight. MIME::Lite is a good alternative.


      Always keep a song in your heart.
      It's like karaoke for the voices in your head.
        Cool, I hadn't seen that one!

        Of course, the original query had to do with parsing MIME, and MIME::Lite doesn't seem to do that. From the docs:

        MIME::Lite is intended as a simple, standalone module for generating (not parsing!) MIME messages...

        Peace,
        -McD