View Full Version : Newline
premshree
09-22-2002, 07:21 PM
How do I print something in a new line in the terminal?
premshree
09-23-2002, 09:43 AM
Ok, I got it.
printf "\n";
I was using
print '\n';
which did not work.
:)
Mouldy_Goat
09-25-2002, 04: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.
premshree
09-26-2002, 03:27 PM
Yes, I know. I realised that later while working on my script :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.