I don't do any CGI or WWW stuff in perl, but a brief review of the CGI docs indicates that you can use the remote_user() method to get the remote user's name. As I see it, you're trying to access the environment variable REMOTE_USER on the server.
Also, the log shows a basic authentication problem, so you may be having trouble a bit before your code gets a chance to do much. I think I'd track down one of the CGI tutorials, or investigate one of the newer perl WWW frameworks that people are talking about.
When your only tool is a hammer, all problems look like your thumb.