open filehandle, filename
Opens the file given by filename, and
associates it with filehandle. If filehandle is omitted, the
scalar variable of the same name as the filehandle must contain the
filename. (And you must also be careful to use "
or die" after the
statement rather than "
|| die", because the precedence of
is higher than list operators like
If filename is preceded by either
< or nothing, the file
is opened for input (read-only). If filename is preceded by
>, the file is opened for output. If the file doesn't exist,
it will be created; if the file exists, it will be overwritten with
>. Preceding the filename with
opens an output file for appending. For both read and write access,
+ before either
A filehandle may also be attached to a process by using a piped
If the filename begins with
|, the filename is interpreted as
a command to which output is to be piped. If the filename ends
|, the filename is interpreted as a command which pipes
input to you.
You may not have an
open command that pipes both
in and out.
Any pipe command containing shell metacharacters is passed to
the shell for execution; otherwise, it is executed directly by
Perl. The filename "
-" refers to
STDIN, and "
>" refers to
non-zero upon success, the undefined value otherwise. If the
a pipe, the return value happens to be the
process ID of the subprocess.