http://www.perlmonks.org?node_id=246505


in reply to Constructing HTML tables with CGI.pm

What the others have said is good and answers your question, but if you're going to be doing a lot of stuff like this, consider using HTML::Template or some other templating system. Most support loops in the template.