func sez :
I would appreciate your comments/criticism on the script.
sub page_body { # The body area and closing tag print <<XHTMLBODY; <body> </body> </html> }
this doesn't even compile, but that's probably a bad copy & paste problem -- you forgot the end XHTMLBODY.
Once that's fixed, we get the following output :
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; chartset=iso-8859-1" /> <meta name="author" content="mynamehere" /> <meta name="copyright" content="mynamehere" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <title>PUT-YOUR-TITLE-HERE</title> </head> <body> </body> </html>
Not bad. It's valid XHTML, and it doesn't look too bad. You've accomplished what you set out to do.

However, through the use of CGI, this code can be compacted :
use CGI::Fast qw(start_html endhtml); print start_html(-title=>'PUT-YOUR-TITLE-HERE', -enctype=>'iso-8859-1', -meta=>{ 'author'=>'my name here', 'copyright'=>'my name here', 'keywords' => '', 'description' =>'' }, ), end_html ;
which outputs
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head><title>P +UT-YOUR-TI TLE-HERE</title> <meta name="description" content="" /> <meta name="author" content="my name here" /> <meta name="keywords" content="" /> <meta name="copyright" content="my name here" /> </head><body http-equiv="text/html" enctype="iso-8859-1"></body></html +>
Pretty similar (the encoding in the xml header differs and the DTD is XHTML Basic, not Strict, and CGI adds the http-equiv and enctype to the body tag.). If this isn't too big a difference, you could cut down your code to far fewer lines. If you're concerned about readability, substitue CGI::Pretty for CGI::Fast. (Wouldn't a CGI::Fast::Pretty be nice?)

In reply to the finest hand rolled XHTML known to man vs. evil factory produced XHTML (boo) by boo_radley
in thread Making a 'blank' xhtml page - request for comments by func

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.