Honestly, the simplest way to do this is to use
HTML::FillInForm. Then you can keep everything in the template and not have to do any HTML generation in the perl code. And if you are using
CGI::Application with
CGI::Application::Plugin::ValidateRM then it's even easier, since it does it for you.
-- fast, working, cheap - pick two