Pingu has asked for the wisdom of the Perl Monks concerning the following question:

The claymation penguin speaks again... Kind of related to node 64720 - I too have noticed that the W3C validator page chokes on the XML doctype that CGI.pm produces. I like to write valid html even when it's dynamically created and I can't work out how to do it. How can I make CGI output a decent doctype header, darn it? I've read the pod and can't find anything useful but maybe I've skipped something. I kind of imagined I could do something like -
use CGI qw(:standard); print header(-doctype=>'-//W3C//DTD HTML 4.01 Transitional//EN');
- but I can't. All help, thoughts, comments or fresh fish gratefully accepted.

Pingu
---
"Give me a fish and I'll not go hungry - Teach me to fish and I'll be a happy penguin"

Replies are listed 'Best First'.
Re: CGI.pm / !Doctype query
by Masem (Monsignor) on Jun 02, 2001 at 01:43 UTC
    First, you can disable CGI's XHTML output and revert it to HTML3 output with the pragma -no_xhtml in the "use CGI" line.

    Also, the doctype should be just before the opening HTML tag, but after the double carriage returns from the header, so you could just print out the doctype line; however, CGI.pm does not appear to allow you to override the default DOCTYPE line that it prints out with start_html. So you might want to drop back to the first suggestion.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: CGI.pm / !Doctype query
by shotgunefx (Parson) on Jun 02, 2001 at 01:44 UTC
    I believe you change the DTD CGI.pm uses with
    default_dtd('text of DTD to use');


    -Lee

    "To be civilized is to deny one's nature."
Re: CGI.pm / !Doctype query
by CharlesClarkson (Curate) on Jun 04, 2001 at 09:56 UTC

    The CGI.pm online docs mention:

    $query->default_dtd('-//W3C//DTD HTML 4.01 Transitional//EN'); print $query->start_html( -title => 'Secrets of the Pyramids', -author => 'fred@capricorn.org', -dtd => 1);
    HTH,
    Charles K. Clarkson