
japhy
Enthusiast
Mar 6, 2000, 6:15 AM
Post #8 of 9
(834 views)
|
|
Re: Creating directories and files????
[In reply to]
|
Can't Post
|
|
Oops, I'm sorry, I forgot the oct() in the "777" example. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> mkdir $dir, 0777; mkdir $dir, oct("777"); mkdir $dir, oct("0777"); # BUT DON'T DO mkdir $dir, oct(0777); </pre><HR></BLOCKQUOTE> Perl converts octal and hexadecimal numbers to decimal when it sees them as numbers (not strings). As for mkdir() not making your directories 0777, that is because your umask() setting is 0022. To get around that, you CAN use chmod() after you've made the directory, or can use Perl's umask() function: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $old = umask 0; # $old is previous umask() mkdir $dir, 0777; umask $old; </pre><HR></BLOCKQUOTE>
|