Nihil Angst has asked for the wisdom of the Perl Monks concerning the following question:

I get the following error message when I try to run
the script below: "Your script produced this error:
Can't find string terminator "ENDHTML" anywhere
before EOF at ./HTML.cgi line 8. " What do I need
to do in order to make this script run?

Thanks in advance for any help you can give.
require TripodCGI; $CGI = TripodCGI; $firstName = $CGI->param('firstName'); $lastName = $CGI->param('lastName'); $Age = $CGI->param('Age'); print "Content-type: text/html\n\n"; print <<ENDHTML; <HTML> <HEAD> <TITLE>CGI Test</TITLE> </HEAD> <BODY> <H2>Congratulations!</H2> <P>We're glad to see you $firtName, members of the $lastName family ar +e always welcome here. It's hard to believe that you're already $Age +years old. My how time flies.</P> </BODY></HTML> ENDHTML

Replies are listed 'Best First'.
Re: Having trouble printing HTML page
by Ovid (Cardinal) on Aug 15, 2002 at 19:00 UTC

    One of the sneaky issues with HERE docs is that they require at least one line after the string terminator. Edit the file and hit 'Enter' after the final ENDHTML. That should take care of it.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Having trouble printing HTML page
by derby (Abbot) on Aug 15, 2002 at 19:01 UTC
    Is your closing ENDHTML preceeded by any white space? If it's not flush left, you will get the error message you describe.

    -derby

Re: Having trouble printing HTML page
by Nemp (Pilgrim) on Aug 15, 2002 at 19:03 UTC

    I had a similar problem to this and it ended up being caused by the fact I had not pressed enter after the ENDHTML close of the here document. As far as I'm aware the "ENDHTML" needs to be on a line on its own with no whitespace and you need to have a new line character straight after it aswell

    HTH,
    Neil

Re: Having trouble printing HTML page
by krisahoch (Deacon) on Aug 15, 2002 at 20:42 UTC

    Nihil Angst,

    I am in agreement with both Ovid, and derby. I would like to offer one suggestion though.

    The following HERE style is deprecated.

    print <<ENDHTML; .... .... .... ENDHTML #Notice there is another line here before EOF, #and that ENDHTML is flush to the left

    You should use quotes around the ENDHTML section.

    print << 'ENDHTML'; .... .... .... ENDHTML #Notice there is another line here before EOF, #and that ENDHTML is flush to the left

    In both examples there is an extra line before the EOF can be reached.
    Both examples also show ENDHTML is flush to the left most margin.

    Just my two cents - Kristofer

Re: Having trouble printing HTML page
by vek (Prior) on Aug 15, 2002 at 19:04 UTC
    Hmm. Are you sure you did a cut & paste instead of re-typing the code. It works fine for me, I just removed the CGI components:
    print <<ENDHTML; <HTML> <HEAD> <TITLE>CGI Test</TITLE> </HEAD> <BODY> <H2>Congratulations!</H2> <P>We're glad to see you $firtName, members of the $lastName family ar +e always welcome here. It's hard to believe that you're already $Age +years old. My how time flies.</P> </BODY></HTML> ENDHTML
    And it runs fine :
    $perl -c foo.pl foo.pl syntax ok $foo.pl <HTML> <HEAD> <TITLE>CGI Test</TITLE> </HEAD> <BODY> <H2>Congratulations!</H2> <P>We're glad to see you , members of the family are always welcome he +re. It's hard to believe that you're already years old. My how time f +lies.</P> </BODY></HTML> ENDHTML
    -- vek --