On Jun 7, David Gilden said:
>@colors = qw[ #F0F8FF #00FFFF #7FFFD4 #F0FFFF #F5F5DC #FFE4C4 #4169E1
>#8B4513 #FA8072 #F4A460 #2E8B57 #A0522D ];
>
>
># choose a color!
>$color_choice1 = rand $#colors;
You're never going to select "#A0522D" this way -- you need to use
rand(@colors), not rand($#colors). Read the rand() docs -- it returns x
such that 0 <= x < ARG.
I would splice() the array after I get the first color from it.
$first = splice @colors, rand(@colors), 1;
$second = splice @colors, rand(@colors), 1;
That way, I always get two different colors.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **