my @colors = [ qw ( red blue ) ]; foreach my $ix(0..$#data) { printf "%s", $colors[($ix % 2)],$data[$ix]; }