In Unix, \n is <lf>, or ASCII 10, \r is <cr> or ASCII 13. So you need "\r\n"
to get what you want.

But on Windows, if you print "\n", it will write out a <cr><lf>. To prevent
that, use "binmode". The following code should work on both Unix and
Windows:

open O, ">xx.out";
binmode O;
print O "line1\r\n";
print O "line2\r\n";
close O;

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Frank Speiser
Sent: Monday, February 05, 2001 2:15 PM
To: [EMAIL PROTECTED]
Subject: [Boston.pm] New Line

Hello Everyone,

I have a quick question and I haven't been able to find the answer in
any of my many books on Perl. Someone in here might know off the top of
their head:

In Perl, this is 5.x running on a Unix environment, what does the
newline (\n) mean literally. Is it the Unix standard <lf> or is it
<cr><lf>?

I am trying to put together a file with the record separator as
<cr><lf>. Will \n do it, and if not where can I get the ascii
equivalents to those characters?

Like Bartles and James, thanks for your support.

-Frank

Reply via email to