Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

terminator error for END....why?

Status
Not open for further replies.

princesstippytails

Technical User
Oct 28, 2002
66
US
Hi,

I have this code I am running:
#!/usr/bin/perl

@teams = ("Red Sox", "Blue Jays", "Yankees", "Giants");
@cities = ("Boston", "Toronto", "New York", "San Francisco");

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

print &quot;<html><body>&quot;;
print <<END;

<table border=1>
<tr>
<th>Baseball Team</th>
<th>Host City</th>
</tr>

<tr>
<td>$teams[0]</td>
<td>$cities[0]</td>
</tr>
<tr>
<td>$teams[1]</td>
<td>$cities[1]</td>
</tr>
<tr>
<td>$teams[2]</td>
<td>$cities[2]</td>
</tr>
<tr>
<td>$teams[3]</td>
<td>$cities[3]</td>
</tr>

</table>

</body></html>

END

When I run it I get an error:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


Can't find string terminator &quot;END&quot; anywhere before END at C:\Inetpub\ Programming\baseball.pl line 9.

Can you tell me why it won't read it?

thanks
ptt :)
 
Do other Perl scripts run ok from this location? It sounds like it could be a server thing.

One other thing, make sure the word END is at the beginning of the line in the program, with a linebreak at the end of the line too. Without that linebreak it may well not work.

Matt.
 
Theres a handy little trick for situations like this.

Get rid of the content-type:text/html line, and put the following at the start of your script:

Code:
#!/usr/bin/perl

BEGIN
{
	print &quot;Content-type: text/html \n\n&quot;;
}

my @code = ( <DATA> );

my $code = join &quot;\n&quot;,@code;

eval $code;

print &quot;Error : &quot;.$@ if ( $@ );

__DATA__

Your script follows as normal here

This should work on a lot of simple scripts that you write yourself.

The way it works is by telling perl that your script ( the stuff after __DATA__ ) isn't perl, but data, so when perl first runs, it'll make no effort to understand it. Then, this data section is turned into a string, and perl runs it using eval, which will hopefully catch the errors ( if $@ ), and print them out.
 
Which isn't totally relevant here, as your server has been configured to display error messages - however, others might find this usefull...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top