[Koha-devel] chmod

D Belden K Lyman IV dbkliv at netscape.net
Wed Jul 2 23:40:05 CEST 2003


markj at 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





More information about the Koha-devel mailing list