[% PERL %] # Pobieramy wartości wejściowe. my @types = @{$stash->get('types')}; my @colors = @{$stash->get('colors')}; my %hex = %{$stash->get('defaults')}; # Zastępujemy wartości domyślne danymi z dokumentu rgb2hex.html, jeżeli istnieją. %hex = %{$stash->get('hex')} if $stash->get('hex'); my @headings = ('Attribute', @colors, "Hex"); my ($attributes, %values); # Ustawiamy atrybuty wizualne strony. foreach my $type (@types) { $attributes .= qq!$type="#$hex{$type}"!; # Tworzymy elementy tablicy do wyboru wartości RGB. my @rgb = map{hex} unpack "a2a2a2", $hex{$type}; foreach my $index (0 .. 2) { $values{$type . $colors[$index]} = $rgb[$index]; } } # Udostępniamy zmienne innym znacznikom szablonu. $stash->set(attributes => $attributes); $stash->set(values => \%values); $stash->set(headings => \@headings); [% END %]