[% PERL %] # Get the incoming values. my @types = @{$stash->get('types')}; my @colors = @{$stash->get('colors')}; my %hex = %{$stash->get('defaults')}; # Overlay the default values with the rgb2hex data, if available. %hex = %{$stash->get('hex')} if $stash->get('hex'); my @headings = ('Attribute', @colors, "Hex"); my ($attributes, %values); # Set up the body attributes. foreach my $type (@types) { $attributes .= qq!$type="#$hex{$type}"!; # Create the RGB chooser table elements my @rgb = map{hex} unpack "a2a2a2", $hex{$type}; foreach my $index (0 .. 2) { $values{$type . $colors[$index]} = $rgb[$index]; } } # Make the variables available to the other template tags $stash->set(attributes => $attributes); $stash->set(values => \%values); $stash->set(headings => \@headings); [% END %]

Color Chooser

Enter an RGB value (each between 0 and 255) for the attributes below, and press "Try it!" to see the results.
[% FOREACH heading = headings %] [% END %] [% FOREACH type = types %] [% FOREACH color = colors %] [% END %] [% END %]
[% heading %]
[% type %] [% key = "$type$color" %] [% hex.$type %]
Here is a link