The
DBI::Format module in the
DBI::Shell distribution allows you to output in a variety of formats. The templating modules like
Template::Toolkit and
HTML::Template can be easily used to output many formats. The
DBD::AnyData module can convert from any DBI accessible table to HTML or CSV or XML or Fixed-Length or others. I'd recommend that you not reinvent the wheel on this one.
update - please retitle your node to reflect the subject matter of your question.