Perl doesn't make dir that correct permission

Perl doesn't reflect that I want to make dir and set permission. If I write like this

mkdir('dir', 0777);

but this way will be setting 755. How to solve this problem↓

http://perl.g.hatena.ne.jp/Cress/20080611/1213184541

umask(0);
mkdir('dir', 0777); 

If you want to upload something file, changing permission to 777 of dir for upload and you have to change permission of dir above dir also.