Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

CGI.pm and W3C

by dooberwah (Pilgrim)
on Apr 08, 2002 at 22:06 UTC ( #157580=perlquestion: print w/ replies, xml ) Need Help??
dooberwah has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I want my scripts to conform to the W3C (World Wide Web Consortium) rules for pages, but pages generated by CGI.pm don't pass cleanly through the W3C validation script. CGI.pm doesn't even print out a valid header to determine what type of document it is. Are there any different modules that print out W3C-friendly HTML? Thanks.

-Ben Jacobs (dooberwah)
http://dooberwah.perlmonk.org
"one thing i can tell you is you got to be free"

Comment on CGI.pm and W3C
Re: CGI.pm and W3C
by gav^ (Curate) on Apr 08, 2002 at 22:09 UTC
    Don't use CGI.pm then, there are better ways to generate HTML (hint templates).

    gav^

      I need the CGI.pm functions as well so I can get input from forms. I suppose I could have a script to do the outputting (w/ templates) and a script to read the input (w/ CGI.pm). How does this solution hold up in the real world?

      -Ben Jacobs (dooberwah)
      http://dooberwah.perlmonk.org
      "one thing i can tell you is you got to be free"

        There is no harm at all in using CGI.pm just to read the input... since it's self-loading, the HTML functions only get loaded if you use them, so there's little penalty in using both CGI and templates in the same script.

        Check out the Template Toolkit for a very flexible templating system.

        stephen

Re: CGI.pm and W3C
by cjf (Parson) on Apr 08, 2002 at 22:31 UTC

    What version of CGI.pm are you using? Last I heard the more recent versions print out valid XHTML (I prefer templating systems and don't use it to print HTML often, so I could be mistaken).

    You also have to do a print $q->header('text/html'); or the like to print a header. See the docs for more detail.

Re: CGI.pm and W3C
by Zaxo (Archbishop) on Apr 09, 2002 at 15:02 UTC

    Hmmm...

    $ perl -MCGI=:standard -e 'print header(),start_html("Foo Page"),$/' Content-Type: text/html; charset=ISO-8859-1 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head><title>F +oo Page</title> </head><body>
    That seems ok to me. Version 2.8, but it's been like that for a while.

    After Compline,
    Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://157580]
Approved by jryan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-08-23 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls