my @nums = qw/00 33 66 99 CC FF/; foreach my $r (@nums) { foreach my $g (@nums) { foreach my $b (@nums) { # Do something with $r, $g and $b } } }