It looks like you cannot count on using "$ENV{HOME}" to specify the path to your ".my.cnf" file. Figure out what the absolute path to the intended file is (e.g. it might be "/home/whoever_you_are/.my.cnf"). Remember that the CGI script runs as whatever "user" owns the web server process, and it's likely that "$ENV{HOME}" is undefined for that user.