in reply to I should need about a cgi script
(Please put large blocks of code in optional code-tags... see “Markup in the Monastery.”)
Easily the best way to handle a complex formatting-task like this one is to use a system such as Template::Toolkit. The code that you have now, even (though|if) it actually works, would be extremely hard to maintain. In addition, it is certainly going to be something that The Marketing Department™ will want to change fairly constantly! Trust me, that is not a place where you want to be.
By moving the presentation details out to a template ... which by the way is very fast ... you achieve “separation of concerns.” The Perl code becomes responsible for preparing the data, while the Template is responsible for presentation.
Since the templating is accomplished using very clever Perl-coding tricks voodoo, it is very efficient indeed.