Yesterday kindly Monks gave some very useful advice about how to find out what ALL the characters were in a text file.
It was all part of my efforts to write UNIX files on a Windows based PC.
The next job is to write the UNIX text file (to be created by reading in a Windows file and writing out each line.
Therefore in the print statement I used \012 at the end of the line rather than the usual \n.
I even added binmode to the input and output files. The Perl extract is below.
I then processed this with the code that looked at each character in the line (having set the input file handle using binmode).
I found both ASCII 13 and ASCII 10. I was hoping to find just ASCII 10! I then found that without the \012 I still got an ASCII 13 character at the end of each input line.
How do I stop print giving me the ASCII 13 character at the end of each line?
binmode(TXTIN); binmode(UNIXOUT); while(defined($linein = <TXTIN>)) { chomp($linein); print UNIXOUT "$linein\012"; }

In reply to Writing a UNIX text line - the end character challenge by merrymonk

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.