In addition to the previous advice, you're not using strict (use strict;). Also why not use a templating system (HTML::Template, Template::Toolkit etc) separate your perl code and the HTML?
Comment on Re: Adding dropdown Javascript Calendar to perl cgi