in reply to chmod and oct
The best explanation is in the documentation (perlfunc, in this case), which says, in part
The first element of the list must be the numerical mode, which should probably be an octal number, and which definitely should not a string of octal digits: 0644 is okay, '0644' is not.
It's the bit pattern behind the number that is significant. Octal is used by convention, because the bits that chmod() cares about when specifying file protection are in three groups of three* -- a natural fit for octal. You could just as well specify them in hex or in decimal, though doing so obscures the intent of the operation.
are equivalent.chmod 0777, $file; chmod 0x1FF, $file; chmod 511, $file;
*Additional bits are used for non-protection stuff like setuid, but it's the 9 low-order protection bits that people usually care about.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: chmod and oct
by mce (Curate) on Dec 06, 2002 at 08:48 UTC | |
by dws (Chancellor) on Dec 06, 2002 at 08:55 UTC |