Hello All,

I am trying to find where the error is when I compile this Perl script but I can't seem to locate it. It is stating that it "Can't find the string terminator "FOOTER" anywhere before EOF at reddrill.pl line 54. I have went through and checked for extra spaces but no luck. I recieved the same error for the HEADER portion but I corrected that one. Does anyone have any idea possibly?

Regards,

#!C:\XAMPP\perl\bin -w
use English; #allow long built-in variable names
#this line sets the MIME type
print "Content-type: text/html\n\n";
print <<HEADER;#remember: no spaces after << !
<html>		<!-- start tag for the HTML page -->
<head>	<!-- header data like the window title -->
<title>Red Drill</title>
#Cascading Style Sheet(CSS)definitions (and/or links) go here JavaScript or VBScript function definitions and/or links.
</head>
<body>	<!-- the page's main HTML code -->
HEADER
use vars qw ($StockName $LastPrice $PrevClose $High $Low $Change $PctChange); 
# return argument with two decimal places
sub twodec
{
return sprintf("%0.2f", $_[0]);
}# read stock data
open STOCKS, "StocksQuotes.csv" #open input file
	or die print "<i>Processing error:&nbsp;</i> $OS_ERROR.";
	my @quotes = <STOCKS>;		#read data all at once
close STOCKS;			#close input file
# display page header, read file and start table
print "<h3>Stock Quotes</h3>\n";
print "<table border ='1' cellpadding='5' cellspacing='0'>\n";
#process each line of the file in turn
foreach $line (@quotes)  #$line is the variable for each line returned from the file
{
($StockName, $LastPrice, $PrevClose, $High, $Low, $Change, $PctChange) = split(",", $line);#it takes each line and analyzes if the first line equals $StockName if so, it then takes each data in the line and splits with a comma and then places each one in each row.
if ($StockName eq "Name") #column heads.  The first row of the spreadsheet is the header rows. And the first cell is the Name column
{
print "<tr>\n";
print " <th>$StockName</th>\n";
print " <th>$LastPrice</th>\n";
print " <th>$PrevClose</th>\n";
print " <th>$High</th>\n";
print " <th>$Low</th>\n";
print " <th>$Change</th>\n";
print " <th>$PctChange</th>\n";
print " </tr>\n";
next ;
}
print "<tr>/n";		#data rows
print "		<td>$StockName</td>\n";
print "		<td align='right'>", twodec($LastPrice), "</td>\n";
print "		<td align='right'>", twodec($PrevClose), "</td>\n";
print "		<td align='right'>", twodec($High),		 "</td>\n";
print "		<td align='right'>", twodec($Low),		 "</td>\n";
print "		<td align='right'>", twodec($Change),	 "</td>\n";
print "		<td align='right'>", twodec($PctChange, 0, -1), "</td>\n";
print "</tr>\n";
}
print "</table>\n";#end table
print <<FOOTER;
</body> <! --end tag for main page section -->
</html>	<!-- end tag for entire HTML page -->
FOOTER

Recommended Answers

All 3 Replies

To fix it, add a newline character immediately after FOOTER. Like this:

#!/usr/bin/perl
use strict;
use warnings;
print <<FOOTER;
</body> <! --end tag for main page section -->
</html>	<!-- end tag for entire HTML page -->
FOOTER
#Had to add newline after FOOTER
#to avoid "Can't find the string terminator..." error

Now output is

</body> <! --end tag for main page section -->
</html>	<!-- end tag for entire HTML page -->

See http://www.perlmonks.org/?node_id=686004 for some explanations.

Thank you very much d5e5 that worked!

~Cheers

You are welcome choosenalpha. Please don't forget to mark this thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.