This was inspired by a javascript I had seen somewhere once, and I found it quite usefull. So as a service to all non-javascript users (namely me) I wrote this perl version.
So to the point, it works! but... other than the non use of CGI.pm I think it still could be improved a bit.. please try it out on your machine or visit
this demo so you can get the whole picture.
Make sure you use the updated code
below, and not the first version.
Any suggestions would be
greatly appreciated!
#!/usr/bin/perl -w
use strict;
my @nums = qw/00 20 40 60 80 A0 C0 FF/;
my $f=0;
my $g=0;
my $h=0;
print "Content-type: text/html\n\n";
print '<html><head><title>Web-Safe Colors</title><head>';
print '<body><table align=center border=0><tr><td>';
while($f<8) {
$g=0;
$h=0;
print '<table width=100% border=1 cellpadding=5>';
while ($g<8){
$h=0;
print "<tr>\n";
while ($h<8){
print "<td align=center bgcolor=\"\#$nums[$f]$nums[$g]
+$nums[$h]\">";
print "<font color=\"\#$nums[7-$f]$nums[7-$g]$nums[7-$
+h]\">";
print "$nums[$f]$nums[$g]$nums[$h]<\/font><\/td> ";
+
$h+=1; }
print '</tr>';
$g+=1;
}
print "<\/table>\n<p>";
$f+=1;
}
print '</td></tr></table></body></html>';
I plan to rewrite it using CGI as soon as I learn CGI.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.