well, you're saying that there is no way, right?

I think he's saying you have to write it, but its better to switch to templates as early as possible, because the alternative is this

monkeypatching one of CGI.pm's very complicated html generation subroutines, no test written for test suite

#!/usr/bin/perl -- use strict; use warnings; use CGI; print CGI->new->start_html( -title => 'searc http://invertor.ru', -author => '@pashanoid', -base => 'true', -meta => { 'keywords' => 'invertor ups search solar wind alternative ene +rgy', 'copyright' => 'MicroART' }, -style => [ { 'src' => '/styles/invertor.css' }, { 'src' => '/styles/ie1.css', 'endif' => 'if lte IE 6' } ], -lang => 'ru-RU', -encoding => 'windows-1251', ); ### Method: _style # internal method for generating a CSS style section #### #~ '_style' => <<'END_OF_FUNC', ## MONKEYPATCHING sub CGI::_style { package CGI; use vars '$XHTML'; my ( $self, $style ) = @_; use DDS; Dump($style); my (@result); my $type = 'text/css'; my $rel = 'stylesheet'; my $cdata_start = $XHTML ? "\n<!--/* <![CDATA[ */" : "\n<!-- "; my $cdata_end = $XHTML ? "\n/* ]]> */-->\n" : " -->\n"; my @s = ref($style) eq 'ARRAY' ? @$style : $style; my $other = ''; for my $s (@s) { if ( ref($s) ) { use DDS; Dump({"WTF", $s, }); my $endif = delete $s->{endif}; my ( $src, $code, $verbatim, $stype, $alternate, $foo, @ot +her ) = rearrange( [qw(SRC CODE VERBATIM TYPE ALTERNATE FOO)], ( '-foo' => 'bar', ref($s) eq 'ARRAY' ? @$s : %$s ) ); use DDS; Dump({ qw{$src} => $src, qw{$code} => $code, qw{$verbatim} => $verbatim, qw{$stype} => $stype, qw{$alternate} => $alternate, qw{$foo} => $foo, qw{@other} => \@other, }); my $type = defined $stype ? $stype : 'text/css'; my $rel = $alternate ? 'alternate stylesheet' : 'styleshee +t'; $other = "@other" if @other; if ( ref($src) eq "ARRAY" ) # Check to see if the $src variable is an array ref +erence { # If it is, push a LINK tag for each one for $src (@$src) { push( @result, $XHTML ? qq(<link rel="$rel" type="$type" href="$src" + $other/>) : qq(<link rel="$rel" type="$type" href="$src" +$other>) ) if $src; $src and $endif and $result[-1] = sprintf "<!--[%s +]>\n%s\n<![endif]-->", $endif, $result[-1]; } } else { # Otherwise, push the single -src, if it exists. push( @result, $XHTML ? qq(<link rel="$rel" type="$type" href="$src" $ot +her/>) : qq(<link rel="$rel" type="$type" href="$src"$oth +er>) ) if $src; $src and $endif and $result[-1] = sprintf "<!--[%s]>\n +%s\n<![endif]-->", $endif, $result[-1]; } if ($verbatim) { my @v = ref($verbatim) eq 'ARRAY' ? @$verbatim : $verb +atim; push( @result, "<style type=\"text/css\">\n$_\n</style +>" ) for @v; } my @c = ref($code) eq 'ARRAY' ? @$code : $code if $code; push( @result, style( { 'type' => $type }, "$cdata_start\n$_\n$cdata_ +end" ) ) for @c; } else { my $src = $s; push( @result, $XHTML ? qq(<link rel="$rel" type="$type" href="$src" $other/ +>) : qq(<link rel="$rel" type="$type" href="$src"$other>) + ); } } @result; } __END__ $ARRAY1 = [ { src => '/styles/invertor.css' }, { endif => 'if lte IE 6', src => '/styles/ie1.css' } ]; $HASH1 = { WTF => { src => '/styles/invertor.css' } }; $HASH1 = { "\$alternate" => undef, "\$code" => undef, "\$foo" => 'bar', "\@other" => [], "\$src" => '/styles/invertor.css', "\$stype" => undef, "\$verbatim" => undef }; $HASH1 = { WTF => { endif => 'if lte IE 6', src => '/styles/ie1.css' } }; $HASH1 = { "\$alternate" => undef, "\$code" => undef, "\$foo" => 'bar', "\@other" => [], "\$src" => '/styles/ie1.css', "\$stype" => undef, "\$verbatim" => undef }; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ru-RU" xml:lang="ru-R +U"> <head> <title>searc http://invertor.ru</title> <link rev="made" href="mailto:%40pashanoid" /> <base href="http://localhost" /> <meta name="keywords" content="invertor ups search solar wind alternat +ive energy" /> <meta name="copyright" content="MicroART" /> <link rel="stylesheet" type="text/css" href="/styles/invertor.css" /> <!--[if lte IE 6]> <link rel="stylesheet" type="text/css" href="/styles/ie1.css" /> <![endif]--> <meta http-equiv="Content-Type" content="text/html; charset=windows-12 +51" /> </head> <body>

I suppose it might be more genetic to accept

{ 'src' => '/styles/ie1.css', -wrapp => [ '<!--[if lte IE 6]>', '<![endif]-->' ], },
but whatever :)

In reply to Re^3: IE specific conditional comments in header of CGI.pm by Anonymous Monk
in thread IE specific conditional comments in header of CGI.pm by pashanoid

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.