Click to See Complete Forum and Search --> : Bareword found where operator expected
crmpicco
06-20-2006, 07:49 AM
This is my code:
#!C:/Perl/bin/perl.exe
# Simple Browser Identification
$browser = "$ENV{'HTTP_USER_AGENT'}";
# Declare Variables
$adrevenue;
$weePit;
$adrevenue = 1000;
$weePit = 'weeCrackPit';
print "Content-type: text/html\n\n";
print "<html>";
print "<head>";
print "<title>Simple Browser Checker</title>";
print "</head>";
print "<body>";
print "You are using $browser to view these pages!\n";
print "<br />";
print "<a href=\"www.crmpicco.co.uk\">Go to Picco\'s Site</a>";
print "<br />";
print "The revenue from the pages are $adrevenue";
print "<table>";
print "<tr>";
print "<td>";
print "Wee Pit is a $weePit";
print "</td>";
print "</tr>";
print "</table>;
print "</body>";
print "</html>";
ENDHTML;
this is my error is am getting:
==========================================
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
Bareword found where operator expected at c:\inetpub\wwwroot\picco\browserCheck.pl line 34, near "print "
==========================================
Line 34 is print "</html>";
Why is this occuring?
Picco
Charles
06-20-2006, 08:01 AM
You've dropped a quatation mark:print "</table>;Do consider using the "HEREDOC" syntax.
crmpicco
06-20-2006, 08:33 AM
thanks Charles, i never noticed that. how does the HEREDOC syntax work? Is that the <<ENDHTML code????
Charles
06-20-2006, 08:37 AM
thanks Charles, i never noticed that. how does the HEREDOC syntax work? Is that the <<ENDHTML code????Yes. It looks like you started using it but abandoned the idea. You've the closing "ENDHTML" but not the opening.
crmpicco
06-20-2006, 08:39 AM
I'm getting this error now....
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 "ENDHTML" anywhere before EOF at c:\inetpub\wwwroot\picco\browserCheck.pl line 15.
========================================
#!C:/Perl/bin/perl.exe
# Simple Browser Identification
$browser = "$ENV{'HTTP_USER_AGENT'}";
# Declare Variables
$adrevenue;
$weePit;
$adrevenue = 1000;
$weePit = 'weeCrackPit';
print "Content-type: text/html\n\n";
print <<ENDHTML;
print "<html>";
print "<head>";
print "<title>Simple Browser Checker</title>";
print "</head>";
print "<body>";
print "You are using $browser to view these pages!\n";
print "<hr>";
print "Hello and Welcome to My Page user from $ENV{'REMOTE_HOST'}\n";
print "<br />";
print "You came from $ENV{'HTTP_REFERER'}"
print "<a href=\"$ENV{'HTTP_REFERER'}\">";
print "Return to the page you were last at.</a>\n";
print "<a href=\"www.crmpicco.co.uk\">Go to Picco\'s Site</a>";
print "<br />";
print "The revenue from the pages are $adrevenue";
print "<table border=\'1\' bordercolor=\'#000000\'>";
print "<tr>";
print "<td>";
print "Wee Pit is a $weePit";
print "</td>";
print "</tr>";
print "</table>";
print "</body>";
print "</html>";
ENDHTML;
line 15 is the <<ENDHTML code..........
Charles
06-20-2006, 08:52 AM
Try ENDHTML and not ENDHTML;. I'll admit, my Perl here-doc synatax is a bit rusty.
crmpicco
06-20-2006, 08:55 AM
yeah, that worked Charles. Having
print <<ENDHTML
and ENDHTML at the end odf the script works GREAT!!!!
i dont need to print everything like I thought i DID!!!
have you got any other tips or things to avoid doing for a Perl nooB
Charles
06-20-2006, 09:01 AM
A couple of tips:
1) Keep playing with things, constantly trying to reduce the number of key strokes.
2) Make sure that you have read http://www.ayni.com/perldoc/perl5.8.0/pod/perlop.html#Quote-and-Quote-like-Operators .
3) Us the CGI.pm module if it's available: http://www.ayni.com/perldoc/perl5.8.0/lib/CGI.html .
4) Have fun.
crmpicco
06-20-2006, 09:27 AM
1. By keystrokes you mean how much code is in the script?
3. CGI.pm, i am presuming that is a downloadable Perl module. Also, i have seen CGI referred to alot, how does it differ from Perl and what advantages does it have?
Cheers.
Picco
crmpicco
06-20-2006, 09:32 AM
#!C:/Perl/bin/perl.exe
# Simple Browser Identification
$browser = "$ENV{'HTTP_USER_AGENT'}";
# Declare Variables
$adrevenue;
$weePit;
$AgePicco;
$AgeSmacker;
$adrevenue = 1000;
$weePit = 'weeCrackPit';
$AgePicco = 22;
$AgeSmacker = 22;
$CombinedAge = $AgePicco+$AgeSmacker;
print "Content-type: text/html\n\n";
print <<ENDHTML
<html>
<head>
<title>Simple Browser Checker</title>
</head>
<body>
You are using $browser to view these pages!\n
<hr>
Hello and Welcome to My Page user from $ENV{'REMOTE_HOST'}\n
<br />
You came from <a href=\'$ENV{'HTTP_REFERER'}\'>THIS PAGE</a>\n
<br />
<a href=\"www.crmpicco.co.uk\">Go to Picco\'s Site</a>
<br />
The revenue from the pages are $adrevenue
<table border=\'1\' bordercolor=\'#000000\'>
<tr>
<td>
Wee Pit is a $weePit
</td>
</tr>
</table>
<div>The combined age of C and B is $CombinedAge</div>
</body>
</html>
ENDHTML
Superb!! That is my script after adding the <<ENDHTML and all the needless 'print' commands, if you can have a <<ENDHTML command and just write the script like a HTML page then why is there a great need for the print command???
Picco
Charles
06-20-2006, 11:20 AM
"<<ENDHTML" isn't a command. "<<" is a quote like operator. In Perl you can define any character or set of characters as a quotation mark. See http://www.ayni.com/perldoc/perl5.8.0/pod/perlop.html#Quote-and-Quote-like-Operators .
crmpicco
06-20-2006, 01:14 PM
i'm not sure what you mean 'a quote like operator' does the << mean that it is the start of a ENDHTML type command?
Charles
06-20-2006, 01:24 PM
"ENDHTML " is not a command. You can use aything that you like with the "<<" operator. #!C:/Perl/bin/perl.exe
print <<athanasius
Content-type: text/html
Whosoever will be saved, before all things it is necessary that he hold the Catholic Faith.
...
This is the Catholic Faith, which except a man believe faithfully, he cannot be saved.
athanasius