<%perl>
  my @headings = ('Attribute', @$colors, 'Hex');

  my ($attributes, %values);

  foreach my $type (@$types) {
    # Ustawiamy atrybuty wizualne strony.
    $attributes .= qq!$type="#$hex->{$type}"!;

    # Tworzymy elementy tablicy do wyboru wartoci RGB.
    my @rgb = map{hex} unpack "a2a2a2", $hex->{$type};

    foreach my $index (0 .. 2) {
      $values{$type . $colors->[$index]} = $rgb[$index];
    }
  }
</%perl>

<body <% $attributes %>>

  <h3>Wybr kolorw</h3>
  Prosz wprowadzi wartoci RGB (midzy 0 i 255) dla atrybutw poniej
  i nacisn &quot;<i>Wyprbuj!</i>&quot;, aby zobaczy rezultat.

  <form action="color.html" method="POST">
    <table width="30%">
      <tr>
% foreach my $heading (@headings) {
        <th align="left"><% $heading %></th>
%}
      </tr>
% foreach my $type (@$types) {
      <tr>
        <td align="left"><% $type %></td>
% foreach my $color (@$colors) {
        <td align="left">
          <input type="text" name="<%$type . $color %>"
            value="<% $values{$type . $color} %>" size="8">
        </td>
%}
        <td align="left"><% $hex->{$type} %></td>
      </tr>
%}
    </table>
    <input type="Submit" VALUE="Wyprbuj!">
    <input type="Reset" VALUE="Wyczy">
  </FORM>
  <a href="http://localhost/">Oto cze.</a>

<%args>
  $types
  $colors
  $hex
</%args>
