cdn lover
01-14-2004, 04:07 PM
When I run a perl script I get theser errors:
syntax error at articles.pl line 38, near ""yes" {" syntax error at articles.pl line 38, near "} else" syntax error at articles.pl line 38, near "}}" Execution of articles.pl aborted due to compilation errors.
the source?:
#!/usr/bin/perl -w
BEGIN {
$| = 1;
open (STDERR, ">&STDOUT");
print qq~Content-type: text/html\n\n~;
}
require 'bodysubs.pl';
#articles.cgi: the article viwer for the pro canada website
$Artnum=$ENV{"QUERY_STRING"}; # Get the request
# Instalize the program's defaulf behavours
$foundart = "no";
$firstline = "yes";
#open the database file, but quit if it dose not exist
open(DB, "/home/cplanet/db/articles.txt") or die('File dose not exist.');
print "Content-type: text/html\n\n";
while(<DB>) {
$line = $_; chomp($line); # Assign the line to $line, then remove line break
# Check for a article terminator
unless($line eq "ENDOFCONTENT") {
if ($firstline eq "yes") { # Is it a header
($id, $author, $title, $description) = split(/\t/, $line);
print "Content-type: text/html\n\n";
&body_top($description, $title);
if($id == $Artnum) {
print "<h1>$title</h1>\n";
print "<font size=\"6\">by $author</font><br><br>\n";
$foundart="yes"; $firstline="no";
}
}
elsif(($foundart eq "yes") and ($firstline eq "no"))
{ print $line; }
else { # At the end of an article
if($foundart eq "yes" {last;} else {$firstline="yes";}}}
unless($foundart eq "yes") {
print "No articles found";
}
syntax error at articles.pl line 38, near ""yes" {" syntax error at articles.pl line 38, near "} else" syntax error at articles.pl line 38, near "}}" Execution of articles.pl aborted due to compilation errors.
the source?:
#!/usr/bin/perl -w
BEGIN {
$| = 1;
open (STDERR, ">&STDOUT");
print qq~Content-type: text/html\n\n~;
}
require 'bodysubs.pl';
#articles.cgi: the article viwer for the pro canada website
$Artnum=$ENV{"QUERY_STRING"}; # Get the request
# Instalize the program's defaulf behavours
$foundart = "no";
$firstline = "yes";
#open the database file, but quit if it dose not exist
open(DB, "/home/cplanet/db/articles.txt") or die('File dose not exist.');
print "Content-type: text/html\n\n";
while(<DB>) {
$line = $_; chomp($line); # Assign the line to $line, then remove line break
# Check for a article terminator
unless($line eq "ENDOFCONTENT") {
if ($firstline eq "yes") { # Is it a header
($id, $author, $title, $description) = split(/\t/, $line);
print "Content-type: text/html\n\n";
&body_top($description, $title);
if($id == $Artnum) {
print "<h1>$title</h1>\n";
print "<font size=\"6\">by $author</font><br><br>\n";
$foundart="yes"; $firstline="no";
}
}
elsif(($foundart eq "yes") and ($firstline eq "no"))
{ print $line; }
else { # At the end of an article
if($foundart eq "yes" {last;} else {$firstline="yes";}}}
unless($foundart eq "yes") {
print "No articles found";
}