Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

I need help with my first CGI

by Hramyzn (Novice)
on Jul 16, 2014 at 18:28 UTC ( [id://1093920]=perlquestion: print w/replies, xml ) Need Help??

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

Hello guys, I've decided to try out the CGI and failed at the simplest possible example. I've found a simple Perl CGI "hello world" program but copy pasted the code to see what would happen and got an error. Also, I'm using Eclipse IDE with EPIC plugin. This is the code:

print "Content-type: text/html\n\n"; print <<HTML; <html> <head> <title>A Simple Perl CGI</title> </head> <body> <h1>A Simple Perl CGI</h1> <p>Hello World</p> </body> HTML exit;

As you see, it's as simple as it gets, but I get the error "Can't find string terminator "HTML" anywhere before EOF". There is HTML written right before "exit;" and I don't know what's wrong. Can anyone help me?

Replies are listed 'Best First'.
Re: I need help with my first CGI
by toolic (Bishop) on Jul 16, 2014 at 18:34 UTC

    Tip #1 from the Basic debugging checklist: diagnostics

    If you're getting this error from a here-document, you may have included unseen whitespace before or after your closing tag or there may not be a linebreak after it.

    Remove the space before the ending HTML:

    print "Content-type: text/html\n\n"; print <<HTML; <html> <head> <title>A Simple Perl CGI</title> </head> <body> <h1>A Simple Perl CGI</h1> <p>Hello World</p> </body> HTML exit;

    See also Troubleshooting Perl CGI scripts

      Oh, that was the problem. Thanks a lot. Although I should have paid more attention instead of immediately posting a question here :/ The worst thing is, I already knew the line would be taken literally (whitespace included) but I was too blind to see it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1093920]
Approved by toolic
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found