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