Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

CGI-HTML printing error
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
}
}




Report this thread to moderator Post Follow-up to this message
Old Post
Anish Kumar K.
12-17-04 08:56 PM


RE: CGI-HTML printing error
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>';


:   }
:  }



















Report this thread to moderator Post Follow-up to this message
Old Post
Charles K. Clarkson
12-17-04 08:56 PM


Re: CGI-HTML printing error
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 sing
le
quotes (') instead of double quotes (").



John
--
use Perl;
program
fulfillment

Report this thread to moderator Post Follow-up to this message
Old Post
John W. Krahn
12-18-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:43 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.