I'm a novice at Perl.

Ran into a problem reading an idrive.com log file on Windows XP computer.

My solution looks like:
my $logopen = open LOGFILE,"<:encoding(UCS-2LE)", $file; seek LOGFILE, 2, 0; local $/ = undef; my $lines = <LOGFILE>; print '<li>'; if ( $lines =~ /Backup Completed/ ) { print "IDrive Backup Completed: "; } else { print "<b>Backup FAILED:</b> "; } print $file . "</li>\n";
According to notepad++ the IDrive log file was UCS-2 LE. Perl would not slurp the file into a string until I specifically used ":encoding(UCS-2LE)" and until I skipped past the first two bytes of the file. If I did not skip the first two byes I would get a "wide character warning" and "$lines = <LOGFILE>" would only capture a few characters out of a 1088 character file.

I'm still wondering:
1. If Perl should have handled the UCS-2LE file without needing to include the encoding or the skipping of bytes
2. If the IDrive log files might be a non-standard or corrupted UCS-2LE

Bruce

In reply to Problems Handling UCS-2LE by Ecurb

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.