Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-22-2002, 07:21 PM   PM User | #1
premshree
Regular Coder

 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
premshree is an unknown quantity at this point
Question Newline

How do I print something in a new line in the terminal?
premshree is offline   Reply With Quote
Old 09-23-2002, 09:43 AM   PM User | #2
premshree
Regular Coder

 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
premshree is an unknown quantity at this point
Ok, I got it.

Code:
printf "\n";
I was using

Code:
print '\n';
which did not work.

premshree is offline   Reply With Quote
Old 09-25-2002, 04:59 PM   PM User | #3
Mouldy_Goat
Regular Coder

 
Join Date: Jul 2002
Location: London, UK
Posts: 126
Thanks: 0
Thanked 0 Times in 0 Posts
Mouldy_Goat is an unknown quantity at this point
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:
Code:
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.
Code:
$count = 4;
printf("%.4d", $count);
# prints out 0004

$count = 3489;
printf("%.4d", $count);
#prints out 3489
Hope that helps.
Mouldy_Goat is offline   Reply With Quote
Old 09-26-2002, 03:27 PM   PM User | #4
premshree
Regular Coder

 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
premshree is an unknown quantity at this point
Yes, I know. I realised that later while working on my script
premshree is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:46 AM.


Advertisement
Log in to turn off these ads.