Question your assumptions. Specifically, validate the input to your script to make sure that it's getting from the web browser the same stuff it seems to be getting from the command line. Validate, validate, validate. This is good pratice even if you're not jumping between environments. Also, try dumping out the %ENV hash both from the command line and script. Check which user Apache is running as, as well as the group. A good test to see if permissions are causing problems would be (assuming you have the ability to do so) to create another user account, and try invoking your CGI script from it. This could be telling since this other account will probably have permissions (with respect to executing your CGI script) similar to Apache.