CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
print <<WTF; ?????

 



69_vette
Deleted

Jan 25, 2000, 10:52 PM

Post #1 of 5 (1533 views)
print <<WTF; ????? Can't Post

I keep getting "premature end of script headers" when I try to use this simple as hell script...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#!/usr/bin/perl
print "Content-type: text/html\n\n";

print <<THIS;

<html>
<title>
hello
</title>
<body>
hello
</body>
</html>

THIS
</pre><HR></BLOCKQUOTE>

Does print << require a module that i'm forgetting OR WHAT???

Thanks for any help...


kencl
User

Jun 11, 2001, 11:27 PM

Post #2 of 5 (1526 views)
Re: print <<WTF; ????? [In reply to] Can't Post

You're forgetting to terminate the quote with a semicolon. Put it on the line immediately after the label and make sure there are no spaces after the closing label. Also, it's better to put single quotes around your label to prevent interpolation. So, what you want is:

print <<'EndOfQuote'; # or whatever label

la de da...

EndOfQuote
;


>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


AICapone
Deleted

Jun 12, 2001, 9:01 AM

Post #3 of 5 (1518 views)
Re: print <<WTF; ????? [In reply to] Can't Post

I just leave blank lines around WHATEVER like:
print <<WHATEVER;
blah blah blah
blah
blah

WHATEVER

#do some else

-----------------------------------------------------------
What is difficlut takes time, what is impossible takes a little longer


randor
User

Jun 12, 2001, 9:41 AM

Post #4 of 5 (1517 views)
Re: print <<WTF; ????? [In reply to] Can't Post

i find this to be the best for me:

print qq~

stuff
stuff
~;

Randor

I Hope this helps...

perl programmers don't die.. they just start writing a new script.


freddo
User

Jun 14, 2001, 3:19 AM

Post #5 of 5 (1505 views)
Re: print <<WTF; ????? [In reply to] Can't Post

Hi 69,

Your script should work, the only point i can think of it breaking is that you may not have a new line at the end. Like this (remove line numbers):

Code
1¦print <<THIS; 
2¦this herescript works
3¦THIS

instead of:

Code
1¦ print <<THIS; 
2¦ this one doesnt
3¦ THIS

This is because perl search for "THIS\n" (or probably something like that, if you see my poview).

btw, did you know you can have two or more herescripts on a line, like this:

Code
print <<THIS,"Another part\n",<<THAT; 
This part
THIS
That Part
THAT
print "Herescripts work great!";

I hope this helps,
freddo

;---
"If ye long for truth and the honest sea, the Perl Navy longs for ye."
Niccolo Machiavelli

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives