Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

I need help with my first CGI

by Hramyzn (Novice)
on Jul 16, 2014 at 18:28 UTC ( #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?

Comment on I need help with my first CGI
Download Code
Re: I need help with my first CGI
by toolic (Chancellor) 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
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? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2014-10-20 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (93 votes), past polls