Home: Perl Programming Help: Beginner:
Newline command


Feb 22, 2001, 8:44 PM

Views: 370
Newline command

I am trying to get a newline (carriage return into my file).

However, when I do:

print $DB "$_\n";

I get a block on the end (as seen in Win Wordpad).

I would like the line that the cursor is on in the data file to be on the next blank line.

What do I need to do in order to get the proper carriage return?

Sean Shrum


Feb 22, 2001, 9:55 PM

Views: 368
Re: Newline command

I was just reading about this in O'Reilly's CGI Programming 2nd ed. \n is line feed and \r is carriage return. Windows uses both to indicate a new line, so what you need is \r\n.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


Feb 23, 2001, 2:25 PM

Views: 358
Re: Newline command

From what I've heard \n will make a newline for Unix, and \r will make a newline for Windows. But if you read it in a bood, it's gotta be better than my ideas. :)

Jeffrey "muinatit" Lamoureux