Is there any way to send screen shots?
Better just to get perl to tell you what's in the file.
As
Athanasius suggested, I suspect that the file really does contain a NULL, and the tool you're using to look at it converts it to a space.
On Windows 7 (perl-5.28.0), I created a file (null.txt) by running:
C:\_32> perl -e "$s = 'x' . chr(0) . 'y';print $s;" >null.txt
I then examined the contents of null.txt by running:
C:\_32> perl -le "open RD, '<', 'null.txt'; $x = <RD>; chomp $x; print
+ ord substr($x, 0, 1); print ord substr($x, 1, 1);print ord substr($x
+, 2, 1); print length $x;"
120
0
121
3
After using your script to create null.txt.new, I then ran the same one liner to ascertain the contents of null.new.txt
C:\_32> perl -le "open RD, '<', 'null.txt.new'; $x = <RD>; chomp $x; p
+rint ord substr($x, 0, 1); print ord substr($x, 1, 1);print ord subst
+r($x, 2, 1); print length $x;"
120
0
121
3
So it looks to me that I also am unable to reproduce the problem.
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.