open FILEHANDLE
[
, FILENAME
]
Opens a file and associates it with
FILEHANDLE
.
open
returns true upon
success. If
is omitted, uses the scalar variable of the same name
FILENAME
as the
FILEHANDLE
.
The following filename conventions apply when opening a file.
FILE
open
FILE
for input. Also "<
FILE
" .
"
"
FILE
open
FILE
for output, creating it if necessary.
">
"
open
in append mode.
">>
FILE
"
FILE
open existing
with read/write access.
"+<
FILE
"
FILE
create new
with read/write access.
"+>
FILE
"
FILE
" read/write access in append mode.
"+>>
FILE
"|
CMD
"
opens a pipe to command
CMD
; forks if
CMD
is ‘ - ’.
CMD
opens a pipe from command
CMD
; forks if
CMD
is ‘ - ’.
"
|"
FILE
may be &
FILEHND
, in which case the new file handle is connected to
the (previously opened) filehandle
FILEHND
. If it is &=
N
,
FILE
will be
connected to the given file descriptor.
pipe READHANDLE, WRITEHANDLE
Returns a pair of connected pipes.
y ]
[
] [
print
FILEHANDLE
LIST
Prints the elements of
, converting them to strings if needed. If
LIST
is omitted, prints by default to standard output (or to the last
FILEHANDLE
selected output channel, see
).
select
y ]
[
] [
printf
FILEHANDLE
LIST
Equivalent to print
.
FILEHANDLE
sprintf
LIST
read FILEHANDLE,
VAR, LENGTH
[
, OFFSET
]
$
Reads
LENGTH
binary bytes from the file into the variable at
OFFSET
.
Returns number of bytes actually read.
seek FILEHANDLE, POSITION, WHENCE
Arbitrarily positions the file. Returns true upon success.
[
]
select
FILEHANDLE
Returns the currently selected filehandle. Sets the current default filehandle
for output operations if
FILEHANDLE
is supplied.
select RBITS, WBITS, NBITS, TIMEOUT
Performs a select(2) system call with the same parameters.
sprintf FORMAT, LIST
Returns a string formatted in the style of printf (3) conventions.
sysopen FILEHANDLE, PATH, MODE
[
, PERMS
]
Performs an open(2) system call. The possible values and flag bits of
MODE
are system-dependent; they are available via the standard module Fcntl .
[
]
sysread FILEHANDLE,
$
VAR, LENGTH
, OFFSET
Reads
LENGTH
bytes into $
VAR
at
OFFSET
.
sysseek FILEHANDLE, POSITION, WHENCE
Performs a seek(2) system call.
syswrite FILEHANDLE, SCALAR, LENGTH
[
, OFFSET
]
Writes
LENGTH
bytes from
SCALAR
at
OFFSET
.
[
]
tell
FILEHANDLE
Returns the current file position for the file. If
FILEHANDLE
is omitted,
assumes the file last read.
18