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:

perl -e "umask 000; mkdir 'a', 0777";ls -ld a
Update:

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 ;)



--chargrill
$,=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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.