For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > December 2004 > CGI-HTML printing error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author CGI-HTML printing error
Anish Kumar K.

2004-12-17, 3:56 pm

Hi
The following program has to print in the CGI...I use perl as well as HTML inside...

When I complile this I get the error as "Can't find string terminator "ERROR_PRINT" anywhere before EOF"

Please help me and also. if there is such combinations like perl CGI and HTML which is the best ways..
is it better to use labels like I used now...



if ($#xmlResponseError>0) {

print <<"ERROR_PRINT";
<TR><TH>The Following Users Error</TH></TR>
ERROR_PRINT
for (my $i=0;$i<$#xmlResponseError ;$i++)
{
print << "ERROR_PRINT";
<TR><TD>
ERROR_PRINT
if (($i%3)==0) {
print << "ERROR_PRINT";
<BR><HR><BR>
ERROR_PRINT
}
print $cgi->p($xmlResponseError[$i]);
print << "ERROR_PRINT";
</TD></TR>
ERROR_PRINT
}
}



Charles K. Clarkson

2004-12-17, 3:56 pm

Anish Kumar K. <mailto:anish@vitalect-india.com> wrote:


: The following program has to print in the CGI...I use perl as
: well as HTML inside...
:
: When I complile this I get the error as "Can't find string
: terminator "ERROR_PRINT" anywhere before EOF"

I believe ERROR_PRINT must be in the first column. I'm
not sure, I very rarely use HERE docs for printing.


: Please help me and also. if there is such combinations like
: perl CGI and HTML which is the best ways..
: is it better to use labels like I used now...

Be consistent. Use CGI.pm routines to print or use direct
HTML. Avoid mixing the two. Be certain your output validates
and remember that CGI.pm outputs xhtml, not HTML by default.


print $cgi->Tr( $cgi->th( 'The Following Users Error' ) );
foreach my $error_no ( 0 .. $#xmlResponseError ) {
print
$cgi->start_Tr(),
$cgi->start_td();

print $cgi->br(), $cgi->hr(), $cgi->br() unless $error_no % 3;

print $cgi->p( $xmlResponseError[$error_no] ),

$cgi->end_td(),
$cgi->end_Tr();
}


: if ($#xmlResponseError>0) {

More common:

if ( @xmlResponseError ) {

: print <<"ERROR_PRINT";
: <TR><TH>The Following Users Error</TH></TR>
: ERROR_PRINT

Don't use HERE docs for every print. It's for
*long* documents.


: for (my $i=0;$i<$#xmlResponseError ;$i++)
: {

When possible, avoid this style of looping. It
takes longer for some of us to see what is happening.


: print << "ERROR_PRINT";
: <TR><TD>
: ERROR_PRINT

Awfully complicated way of saying this. Keep it
simple.

print '<TR><TD>';


: if (($i%3)==0) {
: print << "ERROR_PRINT";
: <BR><HR><BR>
: ERROR_PRINT
: }


print '<BR><HR><BR>' unless $i % 0;


: print $cgi->p($xmlResponseError[$i]);
: print << "ERROR_PRINT";
: </TD></TR>
: ERROR_PRINT

print '</TD></TR>';


: }
: }


















John W. Krahn

2004-12-18, 3:55 pm

Anish Kumar K. wrote:
> Hi


Hello,

> The following program has to print in the CGI...I use perl
> as well as HTML inside...
>
> When I complile this I get the error as "Can't find string
> terminator "ERROR_PRINT" anywhere before EOF"
>
> Please help me and also. if there is such combinations like
> perl CGI and HTML which is the best ways..
> is it better to use labels like I used now...
>
>
> if ($#xmlResponseError>0) {
>
> print <<"ERROR_PRINT";
> <TR><TH>The Following Users Error</TH></TR>
> ERROR_PRINT


Both of the ERROR_PRINT labels have to match so either:

print <<" ERROR_PRINT";
<TR><TH>The Following Users Error</TH></TR>
ERROR_PRINT

Or:

print <<"ERROR_PRINT";
<TR><TH>The Following Users Error</TH></TR>
ERROR_PRINT


> for (my $i=0;$i<$#xmlResponseError ;$i++)
> {
> print << "ERROR_PRINT";
> <TR><TD>
> ERROR_PRINT


Either:

print << " ERROR_PRINT";
<TR><TD>
ERROR_PRINT

Or:

print << "ERROR_PRINT";
<TR><TD>
ERROR_PRINT


> if (($i%3)==0) {
> print << "ERROR_PRINT";
> <BR><HR><BR>
> ERROR_PRINT


Either:

print << " ERROR_PRINT ";
<BR><HR><BR>
ERROR_PRINT

Or:

print << "ERROR_PRINT";
<BR><HR><BR>
ERROR_PRINT


> }
> print $cgi->p($xmlResponseError[$i]);
> print << "ERROR_PRINT";
> </TD></TR>
> ERROR_PRINT


Either:

print << " ERROR_PRINT";
</TD></TR>
ERROR_PRINT

Or:

print << "ERROR_PRINT";
</TD></TR>
ERROR_PRINT


> }
> }


And since none of the strings above involve interpolation you could use single
quotes (') instead of double quotes (").



John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com