Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Print large text into output file

by Anonymous Monk
on Jun 28, 2013 at 14:40 UTC ( #1041263=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to create an HTML page with Perl. The thing is that, when I put the following code inside:
open OUT, ">ResultsTable.html"; print OUT "<html>\n<body>\n"; print OUT "<head>\n"; print OUT <<HEADS script type="text/javascript"> function altRows(id){ if(document.getElementsByTagName){ var table = document.getElementById(id); var rows = table.getElementsByTagName("tr"); for(i = 0; i < rows.length; i++){ if(i % 2 == 0){ rows[i].className = "evenrowcolor"; }else{ rows[i].className = "oddrowcolor"; } } } } window.onload=function(){ altRows('alternatecolor'); } </script> <style type="text/css"> table.altrowstable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 1px; border-color: #a9c6c9; border-collapse: collapse; } table.altrowstable th { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } table.altrowstable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } .oddrowcolor{ background-color:#d4e3e5; } .evenrowcolor{ background-color:#c3dde0; } </style> HEADS print OUT "</head></body></html>\n";
it complains about the last line, something that I haven't "closed" at EOF. What am I doing wrong?

Replies are listed 'Best First'.
Re: Print large text into output file
by daxim (Chaplain) on Jun 28, 2013 at 14:49 UTC
    Statement print OUT <<HEADS isn't terminated with a semicolon.

    Update: Use CSS :nth-child instead of that ghastly Javascript.

Re: Print large text into output file
by ww (Archbishop) on Jun 28, 2013 at 15:06 UTC
    Some browsers may object to the reversal of <body> and <head>.

    Here's a shortened version of what you really want in the html, if you want to be close-to-compliant and want some minimal SEO:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>some sort of title goes here</title> <meta name="DESCRIPTION" content="This is a page to inform you about.. +.. "> <meta name="KEYWORDS" content="'phrase of more than one word', keyword +, etc... "> <script src="map2open.js" language="javascript" type="text/javascript" +> </script> <meta http-equiv="Content-Style-Type" content="text/css"> <link rel="stylesheet" type="text/css" href="tos.css"> </head> # head must close BEFORE body begins; not at the + end as in OP Line57 <body>

    If you didn't program your executable by toggling in binary, it wasn't really programming!

Re: Print large text into output file
by Anonymous Monk on Jun 28, 2013 at 14:50 UTC
     print <<HEAD ; ## MISSING ; HERE
      Ha, silly me! I was stuck it this for quite some time :)
      Thanks to both of you!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1041263]
Approved by marto
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2018-07-19 12:04 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (407 votes). Check out past polls.