Hi Athanasius,

You wrote:

If you know that your command window will always be exactly 80 characters wide, you can get the output you want on Windows by simply omitting the newline character altogether:

The third section of the test program I posted does exactly that. Often I print things to both the console and a log file so it's annoying that they don't look the same if I try to print a partition across the whole line. Limiting my output to one less than the line width takes care of it but I was curious if other monks noticed or cared. I realize it's a very minor issue.

Update: I tried your one-liners with <STDIN>. That's a good demonstration of the issue. If someone wanted to print a full line of characters and then use \r or \b to overwrite characters they could in Linux but not in Windows. If I modify your one-liner for Windows like the following then I can overwrite characters but as soon as the last column is written to then the line advances.

perl -we "print q(-)x79,qq(\b\b);<STDIN>;"

Your demonstration shows the issue is that cmd.exe will advance as soon as the last column is printed to whereas Linux doesn't advance until one character past the last column. This shows it has nothing to do with one or two characters for '\n'.


In reply to Re^2: [OT] Why does newline in Windows print as having width? by Lotus1
in thread [OT] Why does newline in Windows print as having width? by Lotus1

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.