Mistakes (cont) chown -1, $WEB_GID, $file; chmod 640, $file; When setting umask and modes, you probably want octal notation 0640 instead of 640 640 decimal is 01200 octal, ie 'sticky, write for user' These commands operate on file names. When working in directories to which others have write access, this could lead to a race condition. Use filehandle-based functions when possible.