Anish Kumar K. <mailto:[EMAIL PROTECTED]> 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>';


:   }
:  }



















-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to