Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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?

Comment on Print large text into output file
Download Code
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 (Bishop) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2016-02-09 13:03 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (315 votes), past polls