routine chmod

Documentation for routine chmod, assembled from the following types:

role IO

From IO

(IO) sub chmod

Defined as:

sub chmod(Int() $mode*@filenames --> List)

Coerces all @filenames to IO::Path and calls IO::Path.chmod with $mode on them. Returns a List containing a subset of @filenames for which chmod was successfully executed.

chmod 0o755, <myfile1  myfile2># make two files executable by the owner 

class IO::Path

From IO::Path

(IO::Path) method chmod

Defined as:

method chmod(IO::Path:D: Int() $mode --> Bool)

Changes the POSIX permissions of a file or directory to $mode. Returns True on success; on failure, fails with X::IO::Chmod.

The mode is expected as an integer following the standard numeric notation, and is best written as an octal number:

'myfile'.IO.chmod(0o444);          # make a file read-only 
'somedir'.IO.chmod(0o777);         # set 0777 permissions on a directory 

Make sure you don't accidentally pass the intended octal digits as a decimal number (or string containing a decimal number):

'myfile'.IO.chmod:  '0444';        # BAD!!! (interpreted as mode 0o674) 
'myfile'.IO.chmod: '0o444';        # OK (an octal in a string) 
'myfile'.IO.chmod:  0o444;         # Also OK (an octal literal)