Hi, may be you could try to complement the following line of code:

chomp $line;

with this additional one:

$line =~ s/\r//g;

The reason I am suggesting this is that, if I understand correctly what you get, you may be using a Windows file under Unix/Linux or another similar partly incompatible combination.

In this case, chomp is not enough to clean your data from additional invisible characters. Without going into all the details, Windows new lines are composed of two characters (\r\n) and Unix of only one (\n). If you process a Windows file under Unix, Perl believes it is a Unix file and chomp removes the \n character, leaving the \r. In terms of old typewriters or teletypes, \n is the line feed character, whereas \r the carriage return character. If you are left with only the \r character, then the next line may partly overwrite the last one. The ASCII codes for those 2 characters are 10 and 13.

This is just one hypothesis, but your description of the problem makes it quite similar to problems I have encountered a number of times dealing with different platforms. Normal FTP in ASCII mode between platform usually handles the conversion, but binary FTP mode or SFTP often sc*w things up.

I have made my description on differences between Unix and Windows, but you can get similar issues between Mac and Windows, Unix and Mac, VMS and Unix, etc.


In reply to Re: Leading Characters Not Visible for Certain Array Elements While Printing by Laurent_R
in thread Leading Characters Not Visible for Certain Array Elements While Printing by justsomeguy

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.