According to the documentation,
Creates the directory specified by FILENAME, with permi +ssions specified by MASK (as modified by "umask"). If it succ +eeds it returns true, otherwise it returns false and sets $! (e +rrno). If omitted, MASK defaults to 0777. In general, it is better to create directories with per +missive MASK, and let the user modify that with their "umask", +than it is to supply a restrictive MASK and give the user no wa +y to be more permissive. The exceptions to this rule are when +the file or directory should be kept private (mail files, for in +stance). The perlfunc(1) entry on "umask" discusses the choice o +f MASK in more detail.
That's all well and good, but on my system, my default umask is 022, so your code still creates a directory as drwxr-xr-x for me. The follwoing seems to do what you want:
Update:perl -e "umask 000; mkdir 'a', 0777";ls -ld a
I think the docs could be a it more clear that even given a mask for creating directories, mkdir still honors the users umask. - OR I could try READING what I just posted ;)
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}
In reply to Re: Why does unix mkdir and perl mkdir behave differently?
by chargrill
in thread Why does unix mkdir and perl mkdir behave differently?
by tphyahoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |