Code Comments
Programming Forum and web based access to our favorite programming groups.Hi
The following program has to print in the CGI...I use perl as well as HTML i
nside...
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 HTM
L 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
}
}
Post Follow-up to this messageAnish 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>';
: }
: }
Post Follow-up to this messageAnish 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 sing
le
quotes (') instead of double quotes (").
John
--
use Perl;
program
fulfillment
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.