"Here pages" or "here documents" are blocks of text containing embedded variables which are positioned between a start and stop line and which are usually transmitted verbatim to the client. These pages let you include entire HTML and Javascript (or other programs) without any formatting controls at all. Thus you don't need intermixed "print" statements, quotes, or escape characters and can simply transmit HTML or language code entirely without modification. Here is small example of a here page:
print <<END_OF_HTML
 <HTML>
 <HEAD>
 <TITLE> $title_string </TITLE></HEAD>
 <BODY>
 <H3> $header </H3>
 <HR>
 <SCRIPT>

 function is_Alpha( c ) {
    if (  ( c >= 'A' ) && ( c <= 'Z' ) ) return true;
    if (  ( c >= 'a' ) && ( c <= 'z' ) ) return true;
    return false;
 }

 function is_Digit( c ) {
    if (  ( c >= '0' ) && ( c <= '9' ) ) return true;
  return false;
 }
 </SCRIPT>
 </BODY>
 </HTML>
END_OF_HTML
;
The start and stop lines are

print <<END_OF_HTML
and
END_OF_HTML
;

Of course you can use any string of text, not just END_OF_HTML, to delimit the "here" output. Note that the terminating string, in this case END_OF_HTML, *must* start in column 1, but all other text between the start and stop lines can begin in any column. The strings that start with a "$" are variables that are evaluated as the document is transmitted.

There are a few cases where certain characters need to be escaped. For example, "\n" or "\t", which might appear in JavaScript code, must be escaped with a "\", e.g., "\\n" or "\\t". If you fail to do this you will get "end-of-script" warnings when you run the CGI program.