Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Problems with print ID command

by Dougie G (Initiate)
on Jul 01, 2000 at 05:34 UTC ( [id://20703]=perlquestion: print w/replies, xml ) Need Help??

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

Ok, I just learned PERL, oh, two days ago so excuse me if this question sounds idiotic. I'm making a cgi script and recently I've come across a very annoying problem with the print <<SOMETAG; command. When I run the script with the -w command, I get an error saying that it can't find the string terminator before EOF. Well here's an example:
#!/usr/local/bin/perl print "Content-type:text/html\n\n"; print <<END; <html> <body> Bla bla bla </body> </html> END
When run I get the error: Can't find string terminator "END" anywhere before EOF at line 5. What's up with that? Why does it report EOF at line 5? I've used this print command before in other scripts with no problem and I can't figure out what the difference is between now and then. I've also got some scripts that use this print command several times and then the error is only reported with the last instance of the command. Is it just me or is this wierd? I don't know much about this language but I think that the above example should run fine.

Replies are listed 'Best First'.
Re: Problems with print ID command
by takshaka (Friar) on Jul 01, 2000 at 08:00 UTC
    If you're using certain versions of Perl from ActiveState--ie, on Win32--you'll get this error if the terminator is on the last line of the file. Add a blank line after it in this case.

    Otherwise, the problem is as c-era stated.

Re: Problems with print ID command
by c-era (Curate) on Jul 01, 2000 at 06:35 UTC
    When I started with perl I had this problem. END has to be on a line by its self (no white space before or after). Perl on linux doesn't seem to mind white shace after END, but on solaris it did.
(jcwren) Re: Problems with print ID command
by jcwren (Prior) on Jul 01, 2000 at 05:53 UTC
    I think the problem, based on your example, is that you don't have the print statement correctly specified. It should look something like this (always use that "use strict;" and -w flag):
    #!/usr/local/bin/perl -w use strict; print "Content-type:text/html\n\n"; print <<END; <html> <body> Bla bla bla </body> </html> END print "This is the next line of code";
    The key being END must be on a line by itself

    --Chris
Re: Problems with print ID command
by Dougie G (Initiate) on Jul 01, 2000 at 08:29 UTC
    Thanks for all the help, guys. I appreciate it cause I was getting kinda frustrated with such simple code giving an error. The problem was what takshaka suggested. But I didn't know about what c-era said so that will probably aleviate some future headaches. Thanks again!
Re: Problems with print ID command
by ase (Monk) on Jul 01, 2000 at 06:23 UTC
    This works fine for me:
    #!/usr/local/bin/perl print "Content-type:text/html\n\n"; print <<END; <html> <body> Bla bla bla </body> </html> END

    Hope that helps,
    -ase

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found