Make a colorful table For this challenge, you must accept input as a comma-separated list (columns) of a run (rows) of the first letters of any of the colors red, orange, yellow, green, blue, or purple, and output (to stdout) the HTML for a table of those colors.

This is fairly hard to understand, so I'll just give a simple example.

Input:

rgb,gbr,grb


Output (with example screenshot):

&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td style="background-color: red" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: green" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: blue" width="50" height="50"&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td style="background-color: green" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: blue" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: red" width="50" height="50"&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td style="background-color: green" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: red" width="50" height="50"&gt;&lt;/td&gt;
          &lt;td style="background-color: blue" width="50" height="50"&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/body&gt;
&lt;/html&gt;




Note that the HTML you output need not be valid; it just has to work. By "work", I mean that your output will be pasted into a .html file and viewed in the latest (currently, 9/28/13) Chrome (v 29.0.1547.76). The squares must be 50 pixels width and height. You may have whatever padding between them as you want (Chrome automatically uses 1 pixel of padding, even when you specify padding: 0px, so I can't control that).

Input will always be valid (letters will be one of roygbp), but the rows are not guaranteed to have equal amounts of squares in them. For example, roygbp,ooo is valid and should output



This is code-golf, shortest code wins.
Perl: 153 126 124 116 114 characters
s!\w!'&lt;td bgcolor=#'.substr(ff00f90707,yrbxoxgp=~$&amp;&amp;&amp;@-[0],3).' width=50 height=50&gt;'!ge;s!,!&lt;tr&gt;!g;$_=&quot;&lt;table&gt;$_&quot;

Sample run:
bash-4.1$ perl -p table.pl &lt;&lt;&lt; 'rgb,oyp'
&lt;table&gt;&lt;td bgcolor=#f00 width=50 height=50&gt;&lt;td bgcolor=#070 width=50 height=50&gt;&lt;td bgcolor=#00f width=50 height=50&gt;&lt;tr&gt;&lt;td bgcolor=#f90 width=50 height=50&gt;&lt;td bgcolor=#ff0 width=50 height=50&gt;&lt;td bgcolor=#707 width=50 height=50&gt;

Sample output:
bash-4.1$ perl -p table.pl &lt;&lt;&lt; 'yrryyryyryyyrrr,ryyyryryryyyryy,ryryryryryyyrry,yrryyryyrrryryy'