Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Random Color Generator

by Tux (Monsignor)
on Jun 06, 2013 at 13:21 UTC ( #1037453=note: print w/ replies, xml ) Need Help??


in reply to Random Color Generator

Those are the fun projects in our fav scripting language :)

Not to be pedantic, but I rewrote the script to be both more perlish and more xhtml compliant. A lot of your variables are unneeded. The first part is html and css only, the last (very simple) loop incorporates all your fun

use strict; use warnings; print <<"EOH"; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Random Color Generator</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 +-1" /> <style type="text/css"> body { background: white; width: 100%; } h2 { text-align: center; } table { margin: auto; } td { padding: 5px; } .text { background: #e0e0e0; } </style> </head> <body> <h2>Random Color Generator</h2> <table> EOH my $count = 0; for (0 .. 7) { my @color = map { join "" => "#", map { sprintf "%02x", rand 255 +} 1 .. 3 } 1 .. 8; print qq{ <tr>\n}; print qq{ <td class="text">$_</td>\n} for @color; print qq{ </tr>\n}; print qq{ <tr>\n}; print qq{ <td style="background:$_">&nbsp;<br />&nbsp;</td>\n} +for @color; print qq{ </tr>\n}; } print " </table>\n</body>\n</html>\n";

Enjoy, Have FUN! H.Merijn


Comment on Re: Random Color Generator
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-08-31 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls