Name

write

Synopsis

$fh->write (buf, len[, offset])

Like write found in C; that is, the opposite of read. The wrapper for the Perl write function is format_write.

IO::Handle also provides the following methods, which are not described in detail here because they are simply frontends for the corresponding built-in functions. See Chapter 5 for more information.

Method

Description

close

Closes file or pipe

eof

Returns 1 if next read will return end-of-file

fileno

Returns file descriptor for a filehandle

getc

Returns next character from input file

print

Prints a string or comma-separated list of strings

printf

Prints a formatted string

read

Reads data from a filehandle

stat

Returns an array of status information for a file

sysread

Reads data from a filehandle with system call read(2)

syswrite

Writes data to a filehandle with system call write(2)

truncate

Truncates a file to a specified length

Finally, the following methods act on the equivalent Perl variables. See Chapter 4 for more information.

Method

Description

autoflush

If nonzero, forces a flush now and after each write or print (default 0)

format_page_number

Current page number

format_lines_per_page

Current page length (default 60)

format_lines_left

Number of lines left on page

format_name

Name of current report format

format_top_name

Name of current top-of-page format

format_line_break_characters

Current set of linebreak chars for a format

format_formfeed

Formfeed char used by formats (default \f)

format_write

Wrapper for write

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.