POD2-RU

 view release on metacpan or  search on metacpan

lib/POD2/RU/perlfunc.pod  view on Meta::CPAN

changes to the directory specified by C<$ENV{LOGDIR}>.  (Under VMS, the
variable C<$ENV{SYS$LOGIN}> is also checked, and used if it is set.)  If
neither is set, C<chdir> does nothing.  It returns true on success,
false otherwise.  See the example under C<die>.

On systems that support fchdir(2), you may pass a filehandle or
directory handle as the argument.  On systems that don't support fchdir(2),
passing handles raises an exception.

=item chmod LIST
X<chmod> X<permission> X<mode>

=for Pod::Functions changes the permissions on a list of files

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

    $cnt = chmod 0755, "foo", "bar";
    chmod 0755, @executables;
    $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

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

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

You can also import the symbolic C<S_I*> constants from the C<Fcntl>
module:

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

Portability issues: L<perlport/chmod>.

=item chomp VARIABLE
X<chomp> X<INPUT_RECORD_SEPARATOR> X<$/> X<newline> X<eol>

=item chomp( LIST )

=item chomp

=for Pod::Functions remove a trailing record separator from a string

This safer version of L</chop> removes any trailing string
that corresponds to the current value of C<$/> (also known as
$INPUT_RECORD_SEPARATOR in the C<English> module).  It returns the total
number of characters removed from all its arguments.  It's often used to
remove the newline from the end of an input record when you're worried
that the final record may be missing its newline.  When in paragraph
mode (C<$/ = "">), it removes all trailing newlines from the string.
When in slurp mode (C<$/ = undef>) or fixed-length record mode (C<$/> is
a reference to an integer or the like; see L<perlvar>) chomp() won't
remove anything.
If VARIABLE is omitted, it chomps C<$_>.  Example:

    while (<>) {
        chomp;  # avoid \n on last field
        @array = split(/:/);
        # ...
    }

If VARIABLE is a hash, it chomps the hash's values, but not its keys.

You can actually chomp anything that's an lvalue, including an assignment:

    chomp($cwd = `pwd`);
    chomp($answer = <STDIN>);

If you chomp a list, each element is chomped, and the total number of
characters removed is returned.

Note that parentheses are necessary when you're chomping anything
that is not a simple variable.  This is because C<chomp $cwd = `pwd`;>
is interpreted as C<(chomp $cwd) = `pwd`;>, rather than as
C<chomp( $cwd = `pwd` )> which you might expect.  Similarly,
C<chomp $a, $b> is interpreted as C<chomp($a), $b> rather than
as C<chomp($a, $b)>.

=item chop VARIABLE
X<chop>

=item chop( LIST )

=item chop

=for Pod::Functions remove the last character from a string

Chops off the last character of a string and returns the character
chopped.  It is much more efficient than C<s/.$//s> because it neither
scans nor copies the string.  If VARIABLE is omitted, chops C<$_>.
If VARIABLE is a hash, it chops the hash's values, but not its keys.

You can actually chop anything that's an lvalue, including an assignment.

If you chop a list, each element is chopped.  Only the value of the
last C<chop> is returned.

Note that C<chop> returns the last character.  To return all but the last
character, use C<substr($string, 0, -1)>.

See also L</chomp>.

=item chown LIST
X<chown> X<owner> X<user> X<group>

=for Pod::Functions change the ownership on a list of files

Changes the owner (and group) of a list of files.  The first two
elements of the list must be the I<numeric> uid and gid, in that
order.  A value of -1 in either position is interpreted by most



( run in 2.625 seconds using v1.01-cache-2.11-cpan-364913b4093 )