Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Change your current working di ...Change the owership on a list ... (Berikutnya)
Functions for filehandles, files, or directories

Changes the permissions on a list of files

Daftar Isi

  • chmod LIST

    Changes the permissions of a list of files. The first element of thelist must be the numeric mode, which should probably be an octalnumber, and which definitely should not be a string of octal digits:0644 is okay, but "0644" is not. Returns the number of filessuccessfully changed. See also oct if all you have is a string.

    1. $cnt = chmod 0755, "foo", "bar";
    2. chmod 0755, @executables;
    3. $mode = "0644"; chmod $mode, "foo"; # !!! sets mode to
    4. # --w----r-T
    5. $mode = "0644"; chmod oct($mode), "foo"; # this is better
    6. $mode = 0644; chmod $mode, "foo"; # this is best

    On systems that support fchmod(2), you may pass filehandles among thefiles. On systems that don't support fchmod(2), passing filehandles raisesan exception. Filehandles must be passed as globs or glob references to berecognized; barewords are considered filenames.

    1. open(my $fh, "<", "foo");
    2. my $perm = (stat $fh)[2] & 07777;
    3. chmod($perm | 0600, $fh);

    You can also import the symbolic S_I* constants from the Fcntlmodule:

    1. use Fcntl qw( :mode );
    2. chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
    3. # Identical to the chmod 0755 of the example above.

    Portability issues: chmod in perlport.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Change your current working di ...Change the owership on a list ... (Berikutnya)