File Operations

Functions operating on a list of files return the number of files successfully operated upon.

chmod list

Changes the permissions of a list of files. The first element of the list must be the numerical mode. If this is a number, it must be in octal, e.g., 0644. Files can be designated by name and by handle.

chown list

Changes the owner and group of a list of files. The first two elements of the list must be the numerical user ID and group ID. If either is –1, that property is not changed. Files can be designated by name and by handle.

link oldfile, newfile

Creates a new filename linked to the old file.

lstat file

Like stat, but if the last component of the filename is a symbolic link, stats the link instead of the file it links to. file can be an expression evaluating to a filename, or _ to refer to the last file test -l operation or lstat call.

mkdir expr† [ , perm ]

Creates a directory with permissions specified by perm and modified by the current umask. If perm is a number, it must be an octal number. Default value for perm is 0777. See also umask in page 60.

readlink expr

Returns the name of the file pointed to by the symbolic link designated by expr.

rename oldname, newname

Changes the name of a file.

rmdir expr

Deletes the directory if it is empty.

stat file

Returns a 13-element list with file information. file can be a filehandle, an expression evaluating to a filename, or _ to refer to the last file test operation or stat call. Returns an empty list if the stat fails.

Use the standard module File::stat for by-name access to the elements of the list:

Index

Name

Description

0

dev

Device code.

1

ino

Inode number.

2

mode

Type and access flags.

3

nlink

Number of hard links.

4

uid

User ID of owner.

5

gid

Group ID of owner.

6

rdev

Device type.

7

size

Size, in bytes.

8

atime

Timestamp of last access.

9

mtime

Timestamp of last modification.

10

ctime

Timestamp of last status change.

11

blksize

File system block size.

12

blocks

Size, in blocks.

symlink oldfile, newfile

Creates a new filename symbolically linked to the old filename.

truncate file, size

Truncates file to size. file may be a filename or a filehandle.

unlink list

Deletes a list of files.

utime list

Changes the access and modification times. The first two elements of the list must be the numerical access and modification times. When both elements are undef, the current time is used.

The inode change time will be set to the current time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset