#!/usr/bin/perl
print "Content-Type: text/html\n\n";
use CGI ':standard';
print "Hello World!.\n\n";
print "How are You?.";
The \n is probably working just fine. It's just that the script tells
the browser that HTML is sent, and newlines are displayed as spaces in
HTML. Either you can print <br> tags, or you can tell the browser that
the script is sending plain text:
print "Content-Type: text/plain\n\n";
Btw, why are you using CGI when you aren't using it?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
> I am just starting out with Perl scripts running on a Windows Server
> 2003, but the \n newline is not working. The output appears on one
> line. Here is my short code and does anyone know why the \n is not
> working?
>
> #!/usr/bin/perl
> print "Content-Type: text/html\n\n";
Why are you lying about the content type?
> use CGI ':standard';
> print "Hello World!.\n\n";
> print "How are You?.";
If you use CGI, you should use CGI.
Sinan
--
A. Sinan Unur <1u...@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
#!/usr/bin/perl
print "Content-Type: text/plain\n\n";
print "Steady plodding brings prosperity to all.\n";
print "Hasty speculation leads to poverty.";
2. The output is a blank white screen in the browser and when I do a
view source on that page I see this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
3. Last this script ran fine on our windows server, but with the new
Windows 2003 server the code will not work and I do not know why. I
suspect it is not configured properly, but that is not my job, but if
so I would like to be able to suggest to them how to fix Perl. Thanks
for the help....
#! /usr/bin/perl
print "Content-type: text/plain\n";
print "\n";
print "Hello\n";
print "Good bye";
Thank You!
> I have gotten extremely frustrated with Perl on our Windows 2003
> Server.
> 1. I ran this code on our server:
> use CGI ':standard';
> print "Hello World!.\n\n";
> print "How are You?.";
>
> 2. The output is a blank white screen in the browser
This has nothing to do with Perl or your server configuration.
You are not sending any http headers to the browser. When the browser
receives the first line of text, followed by a blank line, it thinks
that that is the http header. There is nothing in that "header" that
explains what the browser is supposed to do with the remaining text.
You really need to learn how http works, but that is a topic for another
newsgroup.
BTW, as someone else has pointed out, there is no reason to use CGI, if
you are not going to use it.
use strict;
use warnings;
# Tell Perl not to buffer output
$|= 1;
print "Content-Type: text/plain; charset=iso-8859-1\n\n";
Can't repro, your program prints beautiful newlines here:
C:\tmp>t.pl
Content-Type: text/html
Hello World!.
How are You?.
C:\tmp>
Your Perl program is working fine, but maybe you are looking at the wrong
place?
jue
> The output appears on one
> line.
> print "Content-Type: text/html\n\n";
[ snip]
> print "Hello World!.\n\n";
That looks like text/plain not the text/html that your code
promised it would be...
--
Tad McClellan SGML consulting
ta...@augustmail.com Perl programming
Fort Worth, Texas