O'Reilly logo

Perl Pocket Reference, 5th Edition by Johan Vromans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required