Just a quick point of "styles" - You say that it's better to use CGI.pm for printing the line with a style attribute. Really it's
than that to create the basic tag with CGI.pm and leave the style to an external Cascading Style Sheet (CSS) file.
Never forget, just because this code is being dynamically generated / templated that you shouldn't use proper HTML "style".
J.