Following is a portion of the script I am using to send HTML page as chunked response. However upon running the script throws compilation errors like :
Number found where operator expected at nph-99_1_1_18.pl line 19, near "print "233" (Might be a runaway multi-line "" string starting on line 18)
#! /usr/bin/perl
print "HTTP/1.1 200 OK\n";
print "Connection: Close\n";
print "Content-type:text/html\n" ;
print "Transfer-Encoding:chunked\n\n" ;
print "96\r\n";
print <<EndText;
<html>
<!-- this chunk is 150 bytes in length-->
<head>
<title>Document Title</title>
<link REL="StyleSheet" TYPE="text/css" HREF="example.css">
</head>
<body>
EndText
print "\r\n\";
print "233\r\n";
print <<EndText;
<!-- this chunk is 563 bytes in length-->
<h1 CLASS="funkyclass" ALIGN="center">Welcome to my home page!</h1>
<br><br>
<p>Hi there! If you are reading this then you have found my home page! Congratulations! I know it can be hard to find my pages, but I bet that you feel lucky now. Now that you are here, please take a look at my page of links to <a HREF="http://www.mysite.com/coolsites.html">cool sites</a> or sign my <a HREF="http://www.mysite.com/guestbook.html">guest book</a></p>
<div CLASS="foo"> My wonderful poetry <br> is available if you are REALLY bored. Why not give it a spin?</div>
EndText
print "\r\n\";
There's an overhead backlash \
in one of your print
statements. There's another one where you copied that line further down, too. It escapes the closing "
, so everything after it is interpreted as a string.
<body>
EndText
print "\r\n\"; # <--- HERE (and also further down)
print "233\r\n";
Do you write your code with an editor/IDE that has syntax highlighting? Turn it on and make strings stick out. That way it will highlight you everything after the escaped "
as a string and you'll not overlook this again.
Also, you should use strict
and use warnings
.