I think the chmod doesn't need oct if it is given a number, so we should use chmod 0644, $file; rather than chmod oct(0644), $file;. Do we have someone who knows for sure, please? -- MJR/slef My Opinion Only and possibly not of any group I know. http://mjr.towers.org.uk/ jabber://slef@jabber.at Creative copyleft computing services via http://www.ttllp.co.uk/ Thought: "Changeset algebra is really difficult."
markj@cloaked.freeserve.co.uk wrote:
I think the chmod doesn't need oct if it is given a number, so we should use chmod 0644, $file; rather than chmod oct(0644), $file;. Do we have someone who knows for sure, please?
Both are correct. The specific call to oct() is useful if the mode is stored in a variable, or is a string.[1] Removing oct() would be a micro-optimisation at best, and could potentially introduce a hard-to-track-down bug: 1. my $mode = 0644 ; chmod( $mode, $file ); 2. chmod( '0644', $file ); 3. chmod( 0644, $file ); You need oct() in the first 2 cases. dbkliv [1] - http://www.perldoc.com/perl5.8.0/pod/func/chmod.html
On Wed, Jul 02, 2003 at 11:39:17PM -0700, D Belden K Lyman IV wrote:
Removing oct() would be a micro-optimisation at best, and could potentially introduce a hard-to-track-down bug:
1. my $mode = 0644 ; chmod( $mode, $file );
2. chmod( '0644', $file );
3. chmod( 0644, $file );
You need oct() in the first 2 cases.
dbkliv
The manpage that you refer to explicitly contradicts what you say above: $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T $mode = '0644'; chmod oct($mode), 'foo'; # this is better $mode = 0644; chmod $mode, 'foo'; # this is best You only need oct() in the second case that you gave. I mention this only in the interest of accuracy, I don't want to start an argument. Matt. -- Matthew Hunt
Matthew Hunt wrote:
On Wed, Jul 02, 2003 at 11:39:17PM -0700, D Belden K Lyman IV wrote:
Removing oct() would be a micro-optimisation at best, and could potentially introduce a hard-to-track-down bug:
1. my $mode = 0644 ; chmod( $mode, $file );
2. chmod( '0644', $file );
3. chmod( 0644, $file );
You need oct() in the first 2 cases.
dbkliv
The manpage that you refer to explicitly contradicts what you say above:
$mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T $mode = '0644'; chmod oct($mode), 'foo'; # this is better $mode = 0644; chmod $mode, 'foo'; # this is best
You only need oct() in the second case that you gave. I mention this only in the interest of accuracy, I don't want to start an argument.
Matt.
Whoops, thanks for the correction Matt. I'd meant to include 4 cases: 1. my $mode = '0644' ; chmod $mode, $file ; # needs oct() 2. chmod '0644', $file ; # needs oct() 3. my $mode = 0644 ; chmod $mode, $file ; # no oct() needed 4. chmod 0644, $file ; # no oct() needed dbkliv
participants (4)
-
D Belden K Lyman IV -
dbkliv -
Matthew Hunt -
MJ Ray