Looking at your code, trying to fix that as it is would benefit neither you nor us. Please head over to the Perl Tutorial Hub
and choose a current resource to start learning from. I can personally recommend Modern Perl 2012 and Ovid's Beginning Perl (which has a nice chapter on web apps).
Especially the latter is recommended because CGI.pm is a module that is very old and will make development very difficult for you (as you are noticing). Better solutions described in that book will make it much easier to write web applications.
As a matter of curiosity, could you please also tell us what resource you are currently learning from and how you found it?