On Windows, text files should look like:

line1 CR LF line2 CR LF line3 CR LF

Where CR stands for Carriage Return (0D) and LF stands for Line Feed (0A).

The unix format is also acceptable on Windows:

line1 LF line2 LF line3 LF

On Macs, you need to use the unix format:

line1 LF line2 LF line3 LF

But for some reason, your text file is using the format ancient Macs (pre OS-X) used:

line1 CR line2 CR line3 CR

That's wrong. <> reads until the first LF (by default), so it perceives the whole file to be one line. Then, when you print it, the terminal causes each line to be written on top of the previous because CR causes the cursor to be moved to the first column of the line.

print "aaaaa\rbbbb\rccc\n"; # Prints cccba

Fix your corrupted file.


In reply to Re: Same code different result in WIN and MAC, help please by ikegami
in thread Same code different result in WIN and MAC, help please by JHG

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.