At risk of furthering my XP slide, are you sure you want to reinvent the form validation wheel when there are modules such as Data::FormValidator (or for CGI::Application fans, CGI::Application::ValidateRM) around?
Blame my missionary zeal on discovering how neat CGI::Application is -- especially the way that the same code can be run as vanilla CGI, or under mod_perl with no modification.