In my defense, I was trying to be a little more CGI.pm about it and adopt the 'poetry mode'. With another hour of giggling I finally cracked what I was so close to before.
This produces the same out put as my original above and uses but a single print statement, in deference to all those post I've seen saying "You don't want all them print statements, use CGI.pm" ;^).
Whether this is better or worse than my original or yours I'll leave it to the reader to make their own conclusions.
#! perl -sw
use strict;
use CGI qw/:standard *table/;
use CGI::pretty;
sub Dlighken {
return sprintf '%02x'x3,
map{ ($_ *= 1+$_[1]) > 0xff ? 0xff : $_ }
map hex, unpack 'A2'x3, $_[0];
}
my @colors = qw/800000 808000 008000 008080 000080 808080 c0c0c0/;
print
table(
Tr( th(' '), th([@colors]) ),
map{
my $scale = $_/10;
Tr(
td($_),
map{
td({bgcolor=>"$_"},[$_])
}
map{
Dlighken($_, $scale)
} @colors
)
}( -5 .. +5 )
)
;
__END__
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|