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

How do I use CGI to generate
    <title>BLAH BLHA</title>
<link rel="stylesheet" type="text/css" href="mycss.css" />
I mean using is the right thing to do right?
Or should I just skip it and do this
print <<HTML; <head> <title>BLAH BLHA</title> <link rel="stylesheet" type="text/css" href="mycss.css" /> </head> HTML
and forget all about doing ...
$cgi->start_html ( -head=> ... bunch of switches I can't keep straight +... );

Replies are listed 'Best First'.
Re: using for LINK tag for Stylesheet
by tedrek (Pilgrim) on Jun 16, 2003 at 06:43 UTC

    I'd suggest using HTML::Template rather than for the HTML aspects ( or another Templating system). Being able to seperate your code from your HTML really becomes nice later :) I see very few people actually using for generating the html, it's pretty much used just for the parameter parsing.

      I'd like suggest to use Embperl or Mason for embedding Perl code into HTML page. See my post about it.
      SV* sv_bless(SV* sv, HV* stash);
Re: using for LINK tag for Stylesheet
by PodMaster (Abbot) on Jun 16, 2003 at 06:50 UTC
Re: using for LINK tag for Stylesheet
by kutsu (Priest) on Jun 16, 2003 at 19:19 UTC

    You might try Ovid's Course.

    "Pain is weakness leaving the body, I find myself in pain everyday" -me

Re: using for LINK tag for Stylesheet
by hacker (Priest) on Jun 17, 2003 at 02:32 UTC

    This should get you started with a few different ideas. I use this code on a production site, and the two stylesheets mentioned fall back gracefully for all browsers tested; 14 total.

    (Pardon the indenting, this is purely for PM formatting only)

    $cgi->start_html(-title => 'Your Snazzy Page', -head => [$cgi->style ({-type => 'text/css', -media => 'all'}, '@import "css/your.css";'), # nonstandard browsers, wget, LWP $cgi->Link({'rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'css/nonstandard.css'}), + # only for printing $cgi->Link({'rel' => 'stylesheet', 'media' => 'print', 'type' => 'text/css', 'href' => 'css/print.css'}), $cgi->Link({'rel' => 'shortcut icon', 'href' => 'favicon.ico', 'type' => 'image/x-icon'})], -author => '', -base => 'true', -bgcolor => '#fff', -meta => { 'keywords' => 'this that', 'copyright' => 'Foo, inc.', 'Cache-Control' => 'no-cache', 'robots' => 'index,follow'}); # Print the environment passed print "<!--\n"; print map{"$_ is $ENV{$_}\n"} sort keys %ENV; print "-->\n"; }