in reply to CRLF and Windows XP SP2
Uncomment the binmode FH and re-runopen (FH,'>',"linefeed.txt"); # binmode FH; # I have added this line print FH "This is a line\r\n" __END__ This is a line^M (viewed under gvim on win XP SP 2)
Output
This is a line (NOTE: no ^M)<p>
perldoc -f binmode On some systems (in general, DOS and Windows-based systems) binmode() +is necessary when you're not working with a text file. For the sake +of portability it is a good idea to always use it when appropriate, a +nd to never use it when it isn't appropriate.
update: Guess I am joining this thread a bit late now!
As others have mentioned CRLF translation is done automatically by Perl. So you are better off using \n in windows and Perl will take care of the rest.
OK what's the scoop with binmode and why did the problem go away?
The reason is that binmode() does not translate \n => CRLF and rather does \n=>LF. Since you are doing \r\n it becomes => CR(i.e. \r)LF(i.e.\n) in binmode!
-SK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CRLF and Windows XP SP2
by slloyd (Hermit) on Aug 12, 2005 at 18:47 UTC | |
by Util (Priest) on Aug 12, 2005 at 19:44 UTC | |
by sgifford (Prior) on Aug 12, 2005 at 19:55 UTC |