I wrote a script to change non-printable characters to spaces:
(The pattern is intended to represent, from left to right:
-The ASCII range containing letters, digits, and punctuation,
-newlines, (Windows: CR-LF)
-newpage
-horizontal tab
)
$ifn=$ARGV[0];$ofn=$ARGV[1]; open IFN, "$ifn" or die "Can't open $ifn:$!\n"; open OFN, ">$ofn" or die "Can't open $ofn:$!\n"; while(<IFN>){ $_ =~ s/[^\x20-\x7e\x0d\x0a\x0c\x09]/ /g; print OFN; };

A problem arose when 0x1A occured in the file: The output file ended on the preceding character!

The name of this character is "substitute", but the control character is ^Z (the EOF marker, I believe. Forgive me, I have to use Windows NT.) My suspicion is that, upon reading this character, <> assumes EOF and leaves the loop.

Is there a way to read past this character safely? What could I do?


In reply to Reading past an artificial EOF? by PiEquals3

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.