Can't find string terminator ...

T

Trudge

This is driving me crazy. I've been programming Perl for several years,
and love the 'here' document capability. I know how it works, and use
it in almost every script I write. I've done the Google group search
and read most of the postings, but no answers to my particular problem.

My development environment is Windows 2000 Pro, running Apache (1.3.29
and 2.0.52) and ActiveState Perl 5.x. I've been developing under this
scenario for a couple of years. I use TextPad as my editor. I haven't
made any changes to anything in the environment. Most of my scripts end
up on *nix boxes, and they all work just fine there.

Lately I noticed this on my home machine when running a test script:
Can't find string terminator "EndOfText" anywhere before EOF at test.pl
line 12 (#1)
(F) Perl strings can stretch over multiple lines. This message
means
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
included
unseen whitespace before or after your closing tag. A good
programmer's
editor will have a way to help you find these characters.

Uncaught exception from user code:
Can't find string terminator "EndOfText" anywhere before EOF at
test.pl line 12.
at test.pl line 12

Here's the code:
#! /usr/bin/perl -w
BEGIN
{
open (STDERR,">>$0-err.txt");
print STDERR "\n",scalar localtime,"\n";
}

use diagnostics;

print "Content-type:text/plain\n\n";

print <<EndOfText;
Why doesn't this work?
EndOfText

I've checked this for syntax umpteen times and can't find anything
wrong. There is a hard-return after 'EndOfText' and it is at the left
margin. I run it through the server in a browser window and from the
command line, but still get the same result.

It's like an EOF character is buried in there somewhere. Which leads me
to wonder if TextPad has been corrupted to save files in a funky format
or something.

Anyone that has any ideas on this would you please respond either here
(for the rest of the group) and/or to my personal email.

Thanks.
--
 
J

John Bokma

Trudge said:
print <<EndOfText;
Why doesn't this work?
EndOfText

Put the cursor just after the t and press return.

Configure your editor to trim tailing spaces/tabs. (Textpad can do this).
 
J

John Bokma

Amer Neely said:
Did both. Still get the same results.


C:\Documents and Settings\John\My Documents>eot.pl
Why doesn't this work?

C:\Documents and Settings\John\My Documents>type eot.pl
print <<EndOfText;
Why doesn't this work?
EndOfText

C:\Documents and Settings\John\My Documents>

You're sure there is a newline after EndOfText?

Might be that you have accidently pressed a key combination that inserts a
hidden character in your terminator. I would delete EndOfText (twice), and
type it in again (once), and copy it.
 
A

Amer Neely

John said:
C:\Documents and Settings\John\My Documents>eot.pl
Why doesn't this work?

C:\Documents and Settings\John\My Documents>type eot.pl
print <<EndOfText;
Why doesn't this work?
EndOfText

C:\Documents and Settings\John\My Documents>

You're sure there is a newline after EndOfText?

Might be that you have accidently pressed a key combination that inserts a
hidden character in your terminator. I would delete EndOfText (twice), and
type it in again (once), and copy it.

Believe me, I've tried everything I can think of to ensure there is
nothing else on that line except the newline at the end. There is
something very strange going on here.

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
A

Amer Neely

Amer said:
Believe me, I've tried everything I can think of to ensure there is
nothing else on that line except the newline at the end. There is
something very strange going on here.

I checked the apache logs and get a slightly different error:
[Mon Oct 23 16:45:12 2006] [error] [client 127.0.0.1] Premature end of
script headers: d:/httpd/cgi-bin/hasbeans/dev/test.pl


--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
X

xhoster

Amer Neely said:
Believe me, I've tried everything I can think of to ensure there is
nothing else on that line except the newline at the end. There is
something very strange going on here.

perl -0777 -ne 'print ord, "\t$_\n" foreach split //' eot.pl

Xho
 
A

Amer Neely

perl -0777 -ne 'print ord, "\t$_\n" foreach split //' eot.pl

Xho
D:\httpd\cgi-bin\hasbeans\dev>perl -0777 -ne 'print ord,"\t$_\n" foreach
split //' test.pl
Can't find string terminator "'" anywhere before EOF at -e line 1.

D:\httpd\cgi-bin\hasbeans\dev>

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
T

Tintin

Trudge said:
This is driving me crazy. I've been programming Perl for several years,
and love the 'here' document capability. I know how it works, and use
it in almost every script I write. I've done the Google group search
and read most of the postings, but no answers to my particular problem.

My development environment is Windows 2000 Pro, running Apache (1.3.29
and 2.0.52) and ActiveState Perl 5.x. I've been developing under this
scenario for a couple of years. I use TextPad as my editor. I haven't
made any changes to anything in the environment. Most of my scripts end
up on *nix boxes, and they all work just fine there.

Lately I noticed this on my home machine when running a test script:
Can't find string terminator "EndOfText" anywhere before EOF at test.pl
line 12 (#1)
(F) Perl strings can stretch over multiple lines. This message
means
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
included
unseen whitespace before or after your closing tag. A good
programmer's
editor will have a way to help you find these characters.

Uncaught exception from user code:
Can't find string terminator "EndOfText" anywhere before EOF at
test.pl line 12.
at test.pl line 12

Here's the code:
#! /usr/bin/perl -w
BEGIN
{
open (STDERR,">>$0-err.txt");
print STDERR "\n",scalar localtime,"\n";
}

use diagnostics;

print "Content-type:text/plain\n\n";

print <<EndOfText;
Why doesn't this work?
EndOfText

I've checked this for syntax umpteen times and can't find anything
wrong. There is a hard-return after 'EndOfText' and it is at the left
margin. I run it through the server in a browser window and from the
command line, but still get the same result.

It's like an EOF character is buried in there somewhere. Which leads me
to wonder if TextPad has been corrupted to save files in a funky format
or something.

What is the hex or octal output of those last 3 lines?
 
X

xhoster

Amer Neely said:
D:\httpd\cgi-bin\hasbeans\dev>perl -0777 -ne 'print ord,"\t$_\n" foreach
split //' test.pl
Can't find string terminator "'" anywhere before EOF at -e line 1.

Yeah, you got to switch it to MSWindows CLI format:

perl -0777 -ne "print ord, qq{\t$_\n} foreach split //" eot.pl

(and change. eot.pl to whatever file name you acutally used)

Xho
 
A

Amer Neely

Tintin said:
What is the hex or octal output of those last 3 lines?

Hmmm. This is interesting. I loaded the file as a binary into TextPad,
and there is 0D 0D 0A after the final 't'. So an extra line-feed seems
to have crept in there.

Good call :) Now to fix the bloody problem.

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
A

Amer Neely

Yeah, you got to switch it to MSWindows CLI format:

perl -0777 -ne "print ord, qq{\t$_\n} foreach split //" eot.pl

(and change. eot.pl to whatever file name you acutally used)

Xho
Thanks.
Got it:
D:\httpd\cgi-bin\hasbeans\dev>perl -0777 -ne "print ord,qq{\t$_\n}
foreach split //" test.pl
35 #
33 !
32
47 /
117 u
115 s
114 r
47 /
98 b
105 i
110 n
47 /
112 p
101 e
114 r
108 l
32
45 -
119 w
13
10

66 B
69 E
71 G
73 I
78 N
13
10

123 {
13
10

9
111 o
112 p
101 e
110 n
32
40 (
83 S
84 T
68 D
69 E
82 R
82 R
44 ,
34 "
62 >
62 >
36 $
48 0
45 -
101 e
114 r
114 r
46 .
116 t
120 x
116 t
34 "
41 )
59 ;
13
10

9
112 p
114 r
105 i
110 n
116 t
32
83 S
84 T
68 D
69 E
82 R
82 R
32
34 "
92 \
110 n
34 "
44 ,
115 s
99 c
97 a
108 l
97 a
114 r
32
108 l
111 o
99 c
97 a
108 l
116 t
105 i
109 m
101 e
44 ,
34 "
92 \
110 n
34 "
59 ;
13
10

125 }
13
10

117 u
115 s
101 e
32
100 d
105 i
97 a
103 g
110 n
111 o
115 s
116 t
105 i
99 c
115 s
59 ;
13
10

112 p
114 r
105 i
110 n
116 t
32
34 "
67 C
111 o
110 n
116 t
101 e
110 n
116 t
45 -
116 t
121 y
112 p
101 e
58 :
116 t
101 e
120 x
116 t
47 /
112 p
108 l
97 a
105 i
110 n
92 \
110 n
92 \
110 n
34 "
59 ;
13
10

112 p
114 r
105 i
110 n
116 t
32
113 q
113 q
123 {
119 w
116 t
102 f
125 }
59 ;
13
10

112 p
114 r
105 i
110 n
116 t
32
60 <
60 <
69 E
110 n
100 d
84 T
101 e
120 x
116 t
59 ;
13
10

119 w
116 t
102 f
13
10

69 E
110 n
100 d
84 T
101 e
120 x
116 t
13
10


D:\httpd\cgi-bin\hasbeans\dev>

I see the CR-LF pair, but should there also be that blank line between
blocks?

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
A

Amer Neely

Amer said:
Hmmm. This is interesting. I loaded the file as a binary into TextPad,
and there is 0D 0D 0A after the final 't'. So an extra line-feed seems
to have crept in there.

Good call :) Now to fix the bloody problem.

Well, I've solved the problem, but it is the weirdest thing I've seen.

In TextPad my default font was verdana. I switched that to courier. Then
copied the code from my test.pl file. Deleted that file, then into a new
file I pasted the code, but now in the new font. Voila. Unbelievable but
true.

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
A

Amer Neely

Michele said:
Not to distrust you, but what about cat -A?


Michele

Hmm. That looks like a *nix command, but I'm running on Windoze 2K. I
did solve the immediate problem as posted, but it still doesn't answer
why this situation arose in the first place. I guess I'll never know.

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
J

John Bokma

Amer Neely said:
Hmm. That looks like a *nix command, but I'm running on Windoze 2K. I
did solve the immediate problem as posted, but it still doesn't answer
why this situation arose in the first place. I guess I'll never know.

I recall that you wrote that there was an additional \x0a in your code.

Furthermore, you can install cat, ls, grep, wget, etc. [1] on a computer
running Windows 2000 (If you don't like Windows, and need to call it
Windoze, why are you using it in the first place?)

[1] http://johnbokma.com/mexit/2006/07/01/
 
X

xhoster

Amer Neely said:
Thanks.
Got it:
D:\httpd\cgi-bin\hasbeans\dev>perl -0777 -ne "print ord,qq{\t$_\n}
foreach split //" test.pl

....
119 w
116 t
102 f
13
10

69 E
110 n
100 d
84 T
101 e
120 x
116 t
13
10

D:\httpd\cgi-bin\hasbeans\dev>

I see the CR-LF pair, but should there also be that blank line between
blocks?

Yes, becuase I print both the ord and the $_ itself. Printing the $_
when $_ contains chr(10) is what is causing the blank lines. You could
make is supress the printing of $_ (but still print ord($_)) when $_ is not
an ordinary character, but I'm too lazy.

Xho
 
A

Amer Neely

John said:
Amer Neely said:
Hmm. That looks like a *nix command, but I'm running on Windoze 2K. I
did solve the immediate problem as posted, but it still doesn't answer
why this situation arose in the first place. I guess I'll never know.

I recall that you wrote that there was an additional \x0a in your code.

Furthermore, you can install cat, ls, grep, wget, etc. [1] on a computer
running Windows 2000 (If you don't like Windows, and need to call it
Windoze, why are you using it in the first place?)

[1] http://johnbokma.com/mexit/2006/07/01/
Yeah it's a love-hate thing. I've run a dual-boot with mandrake for a
while but so many of the other apps I use are Windows-based. And I could
never get wine to run TextPad. But I really should get more experience
with linux.

I do have awk and grep available but never thought of cat.

--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
T

Thrill5

Amer Neely said:
Well, I've solved the problem, but it is the weirdest thing I've seen.

In TextPad my default font was verdana. I switched that to courier. Then
copied the code from my test.pl file. Deleted that file, then into a new
file I pasted the code, but now in the new font. Voila. Unbelievable but
true.

I had a similar experience once before with an extra "0x0d" characters in a
small script I was working on, and I have never used the above text editor,
but with "notepad.exe". I found it pretty quickly using "Wordpad.exe". I
loaded up the script in WordPad because I know from experience that it will
either fix, or display any funky characters in a text file. (It will
successfully load unix text files, and covert them to cr-lf format after
saving) Each line had an offending "0x0d" on the end which showed up in
WordPad as a funky character at the end of each line.

Scott
 
A

Amer Neely

Thrill5 said:
I had a similar experience once before with an extra "0x0d" characters in a
small script I was working on, and I have never used the above text editor,
but with "notepad.exe". I found it pretty quickly using "Wordpad.exe". I
loaded up the script in WordPad because I know from experience that it will
either fix, or display any funky characters in a text file. (It will
successfully load unix text files, and covert them to cr-lf format after
saving) Each line had an offending "0x0d" on the end which showed up in
WordPad as a funky character at the end of each line.

Scott

TP has configuration capabilities to use DOS, Unix, or Mac end-of-line
characters but I've never run into this problem before. What is still
weird is that a change of font should make a difference, as you say. It
seems more likely to be an artifact of something else. Notepad has some
quirky behaviour as well. Try this:
1. Open Notepad
2. Type the text "this app can break" (without quotes)
3. Save the file
4. Re-open the file in Notepad


--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
v: 705.223.3539
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
 
S

Solipsis

Trudge,


Silly question. Is this happening after you ftp the files to the *nix
box? Or before?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top