in reply to Re^2: Creating a random generator
in thread Creating a random generator
Thank you for the fabulous breakdown of issues you see. Let me see if I understand them.
The first item is that you suggested that I add -T to the shebang line. I was already told to add -w (after reading perlrun, I may possibly go to -W instead). Can both be added to the shebang?
Do the following two items duplicate the same thing? If they do, I would choose to keep the first.
use CGI; use CGI::Carp qw(fatalsToBrowser);
print "content-type: text/html \n\n";
I now only have the following in my code...
my @Dice = qw(1d4 1d6 1d8 1d10 1d12 1d20);
@Dice2 became redundant.
You expressed concern for my variable names, with the example being @Radius and $radius. I have been using the capitalized version for the array in the original TableSmith version, and the lowercase version for the phrase fragment for a while now. I can tell the difference.
All of the data in the script is static. As far as I know the arrays will only change if I think of something to add to them and write it into the code manually. The only thing that will change is the amount of times the user wants to run the script and the amount of times each random element will be called. The script as it is now is only a fragment of what is yet to come. I have a lot of markup to add to make this into a web page. I also have several other sub scripts to write that will be used by this one (but each of those must stand alone as well).
The original way I wrote the array dealing with the colors was...
I thought that this would save me a few bytes...my @Color = ( "<span class=\"mut\" style=\"color:#f00;\">red</span>", "<span class=\"mut\" style=\"color:#ff0;\">yellow</span>", "<span class=\"mut\" style=\"color:#0f0;\">green</span>", "<span class=\"mut\" style=\"color:#0ff;\">cyan</span>", "<span class=\"mut\" style=\"color:#00f;\">blue</span>", "<span class=\"mut\" style=\"color:#f0f;\">magenta</span>", "<span class=\"mut\" style=\"color:#fff;\">white</span>", "<span class=\"mut\" style=\"color:#000;\">black</span>" );
But you think a hash is better?my @Colors = ( "f00;\">red", "ff0;\">yellow", "0f0;\">green", "0ff;\">cyan", "00f;\">blue", "f0f;\">magenta", "fff;\">white", "000;\">black" ); my $Color = "<span class=\"mut\" style=\"color:#$Colors[rand @Colors]< +/span>";
How would you make that randomly selected and inserted into the following?my %Colors = ( red =>f00, yellow =>ff0, green =>0f0, cyan =>0ff, blue =>00f, magenta =>f0f, white =>fff, black =>000 );
As soon as I get the entire script working, I will be getting rid of all unnecessary whitespace from it. I just hope that this doesn't go above the amount of bytes I have alloted for it.<span class="mut" style="color:(color code)">(color name)</span>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Creating a random generator
by Limbic~Region (Chancellor) on Sep 26, 2007 at 15:02 UTC |