Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by Enlil (Parson) on Sep 18, 2004 at 23:19 UTC
|
It should work fine as written provided that ENDHEADER is at the very start of a line and nothing else follows it (though I can't tell for sure as you should put <code> tags around your code so we can also see your code formatting which is important in this case). As per perlop: The terminating string must appear by itself (unquoted and with no surrounding whitespace) on the terminating line. HTH -enlil | [reply] |
|
Yes, he's right. The end tag has to be by itself on the line. Here's your code without errors:
sub print_chat
{
print <<ENDHEADER;
Content-type: text/html
<html>
<head><title>My Chat</title>
</head>
</html>
ENDHEADER
}
return 1
(though I don't understand why return 1 is outside the end } ?) | [reply] [d/l] |
|
This is usually because there are spaces before "ENDHEADER"
There should not be spaces before second ENDHEADER.
Regards, Ivan
| [reply] |
|
|
|
serioulsy its working out...
there should be any space between 2nd ENDHEADER..
generally we keep tab and type. thats the exact mistake
| [reply] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by Errto (Vicar) on Sep 19, 2004 at 00:27 UTC
|
From the HTML source for your post, it looks like the word "ENDHEADER" in your code is indented, and thus has some whitespace on the beginning of the line. Delete that and it should work.
| [reply] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by The Mad Hatter (Priest) on Sep 19, 2004 at 01:50 UTC
|
sub print_chat
{
print <<" ENDHEADER";
Content-type: text/html
<html>
<head><title>My Chat</title>
</head>
</html>
ENDHEADER
}
return 1;
Also, wouldn't the return make more sense inside the sub? | [reply] [d/l] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by quai (Novice) on Sep 19, 2004 at 19:10 UTC
|
(when you correct this bug, and wonder why you get an 505 error, add a empty line after the Content-type-line) | [reply] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by Anonymous Monk on Sep 19, 2004 at 06:17 UTC
|
use diagnostics;
print <<FOOOBAR;
__END__
Can't find string terminator "FOOOBAR" anywhere before EOF at - line 2
+ (#1)
(F) Perl strings can stretch over multiple lines. This message me
+ans
that the closing delimiter was omitted. Because bracketed quotes
+count
nesting levels, the following is missing its final parenthesis:
print q(The character '(' starts a side comment.);
If you're getting this error from a here-document, you may have in
+cluded
unseen whitespace before or after your closing tag. A good program
+mer's
editor will have a way to help you find these characters.
Uncaught exception from user code:
Can't find string terminator "FOOOBAR" anywhere before EOF at
+- line 2.
| [reply] [d/l] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by Anonymous Monk on Sep 20, 2004 at 14:27 UTC
|
First, try removing the tab/whitespace before your terminator (i.e. ENDHEADER). Second, your return is in the wrong block. should look more like this:
#!/usr/bin/perl
sub print_chat {
print <<ENDHEADER;
Content-type: text/html
<html>
<head><title>My Chat</title>
</head>
</html>
ENDHEADER
return 1;
}
20040920 Janitored by Corion: Added code tags | [reply] [d/l] |
Re: Can't find string terminator "ENDHEADER" anywhere before EOF
by Anonymous Monk on Sep 20, 2004 at 18:56 UTC
|
IIRC, you have to un-indent the ending ENDHEADER tag so there's no whitespace before or after it. | [reply] |
|
That Perl says:
"Can't find string terminator "" anywhere before EOF"
instead of:
"Help! There's some whitespace before the second one"
is:
TRULY PATHETIC
| [reply] |
|
The behaviour can't be changed because of backwards compatibility. The best that can be done is too clearly document the trap, and that has been done. Perl 6, not constrained by backwards compatibility, does allow whitespace before the token.
| [reply] |
|
to be fair, if you place:
use diagnostics;
at the start of the code it will say:
"If you're getting this error from a here-document, you may have included whitespace before or after your closing tag. A good programmer's editor will have a way to help you find these errors."
| [reply] [d/l] |