Mistakes $WEB_GID=5001 Much better to use $WEB_GID = getgrnam("web"); chdir "/web/www.example.com/htdocs"; ALWAYS check the exit status! At worst, use chdir ... or die; print ... or die; close ... or die; chown ... or die; chmod ... or die;