in reply to
Form validation using CGI
Though it could be fun/good to roll out your own solution, you might be interested in how it has been done (e.g. Data::FormValidator or FormValidator::Simple).
While we're at it might I suggest looking over HTML::Template and HTML::FillInForm
both of which could help you separate out the HTML from your code.
two weeks in the lab can save you two hours in the library...
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo