When I running the following .cgi script, not sure why each print statement is not printing on a new line, even after entering \n. Browser=IE6
See Perl code below: - #!C:/perl/bin/perl.exe -w
-
-
print "Content-type:text/html\n\n";
-
-
use CGI qw(:standard);
-
-
$name = param('name');
-
$age = param('age');
-
$home = param('home');
-
-
print "NAME: $name\n";
-
print "HOME: $home\n";
-
print "AGE: $age\n";
The output I get is all on one line:
NAME: fred HOME: england AGE: 42
11 28452
it is in the source code, but html has no concept of a newline, you have to use html code to format html pages.
When I running the following .cgi script, not sure why each print statement is not printing on a new line, even after entering \n. Browser=IE6
See Perl code below: - #!C:/perl/bin/perl.exe -w
-
-
print "Content-type:text/html\n\n";
-
-
use CGI qw(:standard);
-
-
$name = param('name');
-
$age = param('age');
-
$home = param('home');
-
-
print "NAME: $name\n";
-
print "HOME: $home\n";
-
print "AGE: $age\n";
The output I get is all on one line:
NAME: fred HOME: england AGE: 42
I am going to guess that this script is called from another script because I don't see the HTML in here for the form.
Either way, I went and set the variables (all 3) to values, and it printed just fine on 3 different lines.
Not sure why it would be doing that to you.
Regards,
Jeff
He's viewing the output in a browser. He needs to use HTML code to format the output.
He's viewing the output in a browser. He needs to use HTML code to format the output.
he he, silly me. Wasn't thinking along the lines of displaying in the browser.
Thank you Kevin, formatting the code with HTML worked. Thanks again.
Kevin, why did the <p> tag before \n did the trick - allow me to print on seperate lines?
i.e.
[CODE:Perl]print "NAME: $name<p>\n";
print "HOME: $home<p>\n";
print "AGE: $age<p>\n";[/code]
Thanks
because <p> means a new paragraph in html code. The browser sees the html tags and formats the display accordingly. The browser completely ignores the newlines.
You will need to learn some basic html coding if you are going to write CGI scripts. HTML is very very easy stuff. There are many online resources that can show you the basics of html code. HTML gets a bit more complicated when you use style sheets, refered to as CSS, but it's still fairly easy stuff.
because <p> means a new paragraph in html code. The browser sees the html tags and formats the display accordingly. The browser completely ignores the newlines.
You will need to learn some basic html coding if you are going to write CGI scripts. HTML is very very easy stuff. There are many online resources that can show you the basics of html code. HTML gets a bit more complicated when you use style sheets, refered to as CSS, but it's still fairly easy stuff.
My recommendation would be to go to w3schools.com. Nothing like learning from those who wrote the spec(s).
Regards,
Jeff
Thank you guys for the advise.
add a <br> after each line (i.e. print "NAME: $name\n"; <br> )
Thanks for the help, guys! Now that I've got perl modules under my belt, it looks like I'm only 7 year behind the curve!
No need to use "\n", just use "<br>".
Sign in to post your reply or Sign up for a free account.
Similar topics
by: entoone |
last post by:
print "\t\t<td><bgcolor=#000000><font color=#000000 font
color=#000000 face=Tahoma size=2 ><A href='show.php?searchid=$line'>More
Info</td>\n";
How would I subsittue text for a graphic in php,...
|
by: Michelle |
last post by:
I have tried every variation of the "onchange" statement below without
any actual reloading of the page. I am hoping that the PHP PRINT
statement is constructed wrong, otherwise it is javaScript...
|
by: François Pinard |
last post by:
Hi, people. I hope someone would like to enlighten me.
For any application handling Unicode internally, I'm usually careful
at properly converting those Unicode strings into 8-bit strings before...
|
by: TY |
last post by:
Hi all,
I have this little simple script:
for i in range(10):
for j in range(5000000): pass # Timing-delay loop
print i
When you run it, it behaves as you would expect -- it prints 0...
|
by: no_spam_for_gman |
last post by:
Does db2 have the equivalent of a print statement like SQL server? I
wanted to debug a stored procedure I wrote and wanted to output some of
the values. I couldn't find it in documentation...The...
|
by: jt2 |
last post by:
Hello Perl Gurus!
I'm quite a perl neophyte so I'm looking for help understanding why print doesn't print correctly. This may be a totally stupid error....
He is my program. What it is doing...
|
by: TomEhrhorn |
last post by:
I wrote some VBA code to create web pages (about 100 "identical" pages) with data from Access tables (data is static). Using "Print #1, ..." is a bit onerous but, with loops for repeated table rows...
|
by: JRough |
last post by:
I have this code that switches templates depending on if the user
fills in a form with a request. The request asks for the $mark &
$number. If that request gets input then it displays a list...
|
by: josh wold |
last post by:
Here is my problem. I'm using plink to ssh to devices and pull info off. I need to manipulate this data so that extra 0 at the end is making it difficult.
C:\Python30>python PLINKSSHtest.py...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |