kadams has asked for the wisdom of the Perl Monks concerning the following question:

Greetings oh learned wise ones. I am but a humble
(extremely humble at this point) petitioner seeing wisdom
in the ways of perl. I offer this prize goat and two
prize hens (Tyson brand).

Heres my problem. Im trying to parse some log files.
The files appear to be text files for all
intents and purposes. Yet when i read a line and print
it out it shows as double spaced....like so

     [ 2 3 : 0 9 : 0 7   1 0 - 2 9 ]   P r o c e s s i n g

Did i mention im in a windows xp environment. Ive searched
far and wide but have not fond out how to tame these
log files. I've read up on unicode thinking that the
file might be in such format. However, nothing i've
tried from those sources has helped. Then i remembered
hearing about this bastion of wisdom. What am i not
doing? I just wanna parse and go home...

Thanks,

K

Replies are listed 'Best First'.
Re: How to parse input file and print without double space
by ikegami (Patriarch) on Oct 30, 2008 at 19:54 UTC

    The file is encoded using UCS-2le. You're treating it as if it was encoded using iso-latin-1. Just decode it.

    open(my $log_fh, '<:encoding(UCS-2le)', $log_qfn) or die("Can't open log file \"$log_qfn\": $!\n");
      Many thanks!!! Of course as luck would have it, after
      posting here i found a site that pointed me in that
      direction. Everything i'd read up until then had not
      mentioned ucs2 or utf16. Your post makes it even
      better.

      Thanks much!!!

      K