http://www.perlmonks.org?node_id=117234


in reply to Ongoing chmod lack of success

Check out the umask function.