I want to be able to print just an "LF" to a file.
First, to clear up any ambiguity, I'm going to call the ASCII character with a hex code of 0A and a decimal code of 10 an "LF". I'm also going to call the ASCII character with a hex code of 0D and a decimal code of 15 a "CR".
As a simple test case:
open TEST, ">", "test.data";
select TEST;
print "A" . chr(hex("0A")) . "B" . "\n" . "C" . "\r" . "D";
close TEST;
Logically, when I look at the test.data file with a hex editor I'd expect just a "LF" between the A and B, but instead there are is a "CR" followed by an "LF."
Here is what a hex editor shows is in "test.data" (first line is hex, second line are chars):
41 0D 0A 42 0D 0A 43 0D 44
A CR LF B CR LF C CR D
I was expecting only a "LF" (i.e., 0A) between the "A" (41) and "B" (42) ...
If it helps this is Perl 5.8.8 (ActiveState Perl Build 820) on Windows XP.
Thanks for any advice you may be able to give me.
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.