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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Why oh why does it always happen! (here docs)



May 8, 2001, 5:27 PM

Post #1 of 4 (1230 views)
Why oh why does it always happen! (here docs) Can't Post

I'm always getting problems with here documents. The code :

if ($choix eq 'modifie') {
open (FICHIER,'../data/donneesgt.txt') or die "Problème pour ouvrir le fichier des données du GT";
@donneesfichier = <FICHIER>;
close (FICHIER);
print $objetcgi->header;
print <<EOF;
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../styles.css" type="text/css">
<body bgcolor="#FFFFFF" text="#000000" background="../images/background.gif">
<form name="modifiegt" method="post" action="gestion.cgi">
<table width="750" border="0" cellspacing="0" cellpadding="0" align="center" height="500">

... other HTML + some variables interpolation...


} else {
$date = $objetcgi->param("dategt");
$heure = $objetcgi->param("heuregt");

So I'm almost always confronted with the error about not finding the closing EOF... Could someone tell me at first sight what could be wrong here (and that I can't seem to learn!). Thx!


May 8, 2001, 6:55 PM

Post #2 of 4 (1226 views)
Re: Why oh why does it always happen! (here docs) [In reply to] Can't Post


put a ;


then that should fix your error =) (it happens to everyone little typo's)


May 9, 2001, 1:43 PM

Post #3 of 4 (1216 views)
Re: Why oh why does it always happen! (here docs) [In reply to] Can't Post

Well, I'm not sure about a typo since I used the EXACT same format in other scripts and it worked. I tried with EOF; at the end and it didn't work... I'll try the semicolon on the following line but will only be convinced when i see it working... ;) Thanks!

(This post was edited by Merlin on May 9, 2001, 12:44 PM)


May 9, 2001, 4:19 PM

Post #4 of 4 (1210 views)
Re: Why oh why does it always happen! (here docs) [In reply to] Can't Post

No no no, this is not correct. A 'here doc' does not function in the same was as normal perl statements. What you need is that your EOF that is the last line be on a line all by itself - that means no spaces, no invisible characters, nothing. The best way to check that is to select that line in your text editor - if the line extends past the last character (in this case, the F), then the script will crash.

Also, make sure that the EOF is quoted at the beginning of the here doc:

print <<"EOF";

Otherwise it is a bareword, and perl defintely does not like barewords.

So, basically, you need to make sure that wherever you 'end-of-here-doc' string is, it is all by itself on the line - then you should have no problems!

Hope this helps!

r j o s e p h
"Violence is a last resort of the incompetent" - Foundation


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

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