View Full Version : Newline

09-22-2002, 08:21 PM
How do I print something in a new line in the terminal?

09-23-2002, 10:43 AM
Ok, I got it.

printf "\n";

I was using

print '\n';

which did not work.


09-25-2002, 05:59 PM
The problem with your print '\n'; was not that it wasn't printf() but that it used single quotes, where no interpolation was done - i.e. Perl interpreted the slash-n literally, and printed out a slash-n to your browser. If you were to use print "\n"; it would work as you wanted.

Generally speaking printf is used only if you want to do some kind of formatting, for instance:

printf("%.4d", $count);
Will pad the variable out to have a width of 4 characters, and it will be preceded with 0's, i.e.

$count = 4;
printf("%.4d", $count);
# prints out 0004

$count = 3489;
printf("%.4d", $count);
#prints out 3489

Hope that helps.

09-26-2002, 04:27 PM
Yes, I know. I realised that later while working on my script :)