use strict; use warnings; my @colors = qw (red yellow green cyan blue magenta white gray black); for (1 .. 10) { print $colors[rand(scalar(@colors))]; } __END__ $ perl -wl 637422.pl blue white gray cyan red green red black red red