I have a mail log file (qmail) that I am processing line by line and trying to create a map so it's easier to read the mail log. The problem is that qmail has so many different patches and is logging in so many different ways. For the most part everything processes; however, I continue to get the following errors for some lines:

Malformed UTF-8 character (unexpected end of string)
Malformed UTF-8 character (unexpected continuation byte 0xae, with no preceding start byte)

The lines that are giving me trouble have odd characters like the following:
@400000004be972c621c0b57c 12760 > 4ÿª^PÜd"}^HL\kõ²k½^T<89>Ê<99>-W!í¾²#©Ø#<81> ^Z´o­ Û^Noå»N^U^C^A^@ ß<83><9d>^LÊ^Nq%^R^Z.æÆ9 7GÁæ¨'ÂqîÈ<9d>ÿ7³Ð^M
@400000004be9731d05945a34 13997 < Subject: Don<92>t Pay Retail Prices^M
@400000004be9739614b4c9f4 15230 < Subject: The truth about work-at-home opportunities<85>^M
@400000004be9802004c81154 14584 > 4<81>s^BÇQ»z=Ó^H<98>,ý<96>çVN)rPp^UÚq/£<98>È<9f><93><97><89> ^E<9b>QMbs?^KÖRµ/°o$^H¬^Tüë+

How do I either decode these lines, find out what their encoding is, or skip them all together and stop throwing the warnings?

I have tried using Encode::Guess to no avail, and used the following bit of code to possibly give me an idea, but still getting the Malformed errors:
use warnings; use strict; use Devel::Peek 'Dump'; while ( my $line = <> ) { Dump $line; }


UPDATE: I'd really just be interested in skipping line if it is not UTF-8, or not dealing with these lines at all.

In reply to Malformed UTF-8 character Error by walkingthecow

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.