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.
In Section
Seekers of Perl Wisdom