www.webdeveloper.com
Results 1 to 13 of 13

Thread: Bareword found where operator expected

  1. #1
    Join Date
    Apr 2006
    Posts
    244

    Bareword found where operator expected

    This is my code:

    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

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    You've dropped a quatation mark:
    print "</table>;
    Do consider using the "HEREDOC" syntax.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Apr 2006
    Posts
    244
    thanks Charles, i never noticed that. how does the HEREDOC syntax work? Is that the <<ENDHTML code????

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by crmpicco
    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.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Apr 2006
    Posts
    244
    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.
    ========================================

    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 <<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..........

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Try ENDHTML and not ENDHTML;. I'll admit, my Perl here-doc synatax is a bit rusty.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  7. #7
    Join Date
    Apr 2006
    Posts
    244
    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

  8. #8
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    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....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.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  9. #9
    Join Date
    Apr 2006
    Posts
    244
    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

  10. #10
    Join Date
    Apr 2006
    Posts
    244
    Code:
    #!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

  11. #11
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    "<<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....like-Operators .
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  12. #12
    Join Date
    Apr 2006
    Posts
    244
    i'm not sure what you mean 'a quote like operator' does the << mean that it is the start of a ENDHTML type command?

  13. #13
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    "ENDHTML " is not a command. You can use aything that you like with the "<<" operator.
    Code:
    #!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
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles