I think it would be better if you used CGI.pm to handle your uploads, this will simplify the whole thing and there will be less chance of errors in the code. Almost every book on perl has large sections explaining it's use, or you could go to: http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
Can't remember the last time I saw a script that used a cgi_lib file :)