Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: Random Color Generator by Tux
in thread Random Color Generator by Elihu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found