btw, it's better to use different names for different submit buttons and test only "param exists" (it allows you to change values without strange errors ...).
Instead of compose html chunks, try to look for template modules, for example HTML::Template or Template