|Just another Perl shrine|
Very weird things when printing (may be an encoding issue?)by dottornomade (Initiate)
|on May 30, 2013 at 00:29 UTC||Need Help??|
dottornomade has asked for the
wisdom of the Perl Monks concerning the following question:
it's the first time something like this happens to me.
I have this flat file and simply... the lines gets all messed up when I am printing them on screen, I can't even parse them properly! This is very frustrating. Sadly, I can not attach the file here. When I open and visualize it with gedit, everything looks fine. Here is a snippet:
Basically it alternates two kinds of lines: a title line and a data line.
Now, say I want to print the first line:
And it then prints ALL the odd lines! One after another, ignoring all the lines starting with >. I need to parse this file. When I split the lines with the split command, it considers the last element of an even line to be the whole following odd one, and it ignore the actual true last element. E.g., if I use:
The actual output is:
Note that there is a \n in the middle of the first line, and a -100 value missing.
What's happening? This file was made by a bot interacting with a server...I guess it may be something related to the file encoding, but I have no idea about how to fix it.