[ back to toc ]

Pls Help

Date: 2002/03/18 11:39

Q:
I do not want to use the print statement in my CGI or PERL script. How can
I do this?

A:
Well, it is quite easy, just do not print anything and then you do not
need to use the print statement.

You should have asked: "I need to achieve this and that in my Perl CGI
script *but* I do not want to use the _print_ statement."

If I do not know what you want to achive I can not answer you. Without
knowing the aim, I can advice you to be a sheperd caring after sheep and
you do not need to use the print statement at all.

Regards,
Peter
Q:
Why does the below given program not work?
print "Content-Type: text/html\n\n";
&print_thank_you;
sub print_thank_you {
print<<EOM;
<html><head>
<title>Thnks!</title>
</head>
<h1> Hello </h1>
</html>
EOM
}
When this file is saved as .pl file the response on browser is
'D:\cgi-bin\we.pl' script produced no output
When this file is saved as .cgi file the response on browser is
CGI Error
The specified CGI application misbehaved by not returning a complete set
of HTTP headers. The headers it did return are:
Can't find string terminator "EOM" anywhere before EOF at
D:\cgi-bin\we.cgi line 4.
Why does this happen?
Now when we use print in the same script it works fine

print "Content-Type: text/html\n\n";
&print_thank_you;
sub print_thank_you {
print "<html><head>";
print "<title>Thnks!</title>";
print "</head>";
print "<h1> Hello </h1>";
print "</html>";
}
Why does this happen

A:
I can not be 100% sure, but it seems to be a CR/LF ftp upload problem.
Ensure that the FTP transfer mode is TEXT when you upload the script.

When the Perl interpreter searches for EOM it does not find the line if
there is an extra character after the EOM, namely EOM\r. Scripts that use
this so called "here string" structure are sensitive of the CR/LF
conversion when uploading from Windows to UNIX.

Regards,
Peter

[ back to toc ]