Perl : Cant Find String Terminator

T

TP

i get the message Cant Find String Terminator anywhere before EOF
everytime i try to compile my script..

i hope someone will help

thanks

here is the code

#!/usr/bin/perl

use CGI;
my($query);
$query = new CGI;


##Configuration section

$dbpath = 'db.txt';

$searchwhat = $query->param("searchwhat");
$searchkey = $query->param ("searchkey");

##end of configuration

#Begin search section

open (DB, "<$dbpath") or die ("$!\n");

while (<DB>){
if ($searchwhat eq "all"){
if (/$searchkey/i){
push @matches, $_
};
}

elsif ($searchwhat eq "mtype"){
($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
if ($mtype =~ /$searchkey/i){
push @matches, $_
};
}

elsif ($searchwhat eq "mname"){
($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
if ($mname =~ /$searchkey/i){
push @matches, $_
};
}

elsif ($searchwhat eq "mactor"){
($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
if ($mactor =~ /$searchkey/i){
push @matches, $_
};
}

elsif ($searchwhat eq "mactress"){
($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
if ($mactress =~ /$searchkey/i){
push @matches, $_
};
}

elsif ($searchwhat eq "mdes"){
($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
if ($mdes =~ /$searchkey/i){
push @matches, $_
};
}
close(DB);

#end of search section

#start of response page

$nummatches = @matches;



print<<HTML_RESPOSE

Content-type: text/html
<HTML>
<BODY>

<h2>Your search for $searchkey return $nummatches matches.</h2>


foreach $matchedEntry (@matches){
print "$matchedEntry\n";
}

</BODY>
</HTML>
HTML_RESPONSE
 
D

Darren Dunham

TP said:
i get the message Cant Find String Terminator anywhere before EOF
everytime i try to compile my script..
[snip]

print<<HTML_RESPOSE
HTML_RESPONSE
 
A

A. Sinan Unur

TP said:
i get the message Cant Find String Terminator anywhere before EOF
everytime i try to compile my script..
[snip]

print<<HTML_RESPOSE
HTML_RESPONSE

Don't forget the terminating semi-colon:

print <<HTML_RESPONSE;
<html>
<body>
<ul>
<li>I will learn to spell right</li>
<li>I will learn to spell right</li>
<li>I will learn to spell right</li>
<li>I will learn to spell right</li>
<li>I will learn to spell right</li>
<li>I will learn to spell right</li>
....
</ul>
</body>
</html>
HTML_RESPONSE
 
T

Tad McClellan

Donald LaFramboise said:
print<<HTML_RESPOSE

needs a semicolon at the end of the line,


No it doesn't.



[snip TOFU, a clear indicator of the quality of the followup...]
 
T

Tad McClellan

TP said:
i get the message Cant Find String Terminator anywhere before EOF
everytime i try to compile my script..

print<<HTML_RESPOSE

Content-type: text/html
<HTML>
<BODY>

<h2>Your search for $searchkey return $nummatches matches.</h2>


foreach $matchedEntry (@matches){
print "$matchedEntry\n";
}

</BODY>
</HTML>
HTML_RESPONSE


Others have already pointed out the cause of your syntax error,
but nobody has told you that you can't interpolate code (like that).

A "here-doc" is a way of quoting a _string_, so that foreach() is
NOT seen as code, it is data.

If you want code in the middle of the string, you can have 3
statements: string_part1 then code then string_part2.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top