File I/O

Opening a file

open(FILE, "filename");   Open filename for reading.
open(FILE, "<filename");   Open filename for reading.
open(FILE, ">filename");   Open filename for writing. The file is truncated if it already exists.
open(FILE, ">>filename");   Open filename for writing. The file is appended if it already exists.
open(FILE, "+<filename");   Open filename for reading and writing.

FILE is the file handle name (the convention is to use all uppercase).

Reading from a file

$scalar = <FILE>;   Read one line (including the end-of-line sequence) from the file.
@array = <FILE>;   Read the entire file, one line (including the end-of-line sequence) per array element.

Writing to a file

print FILE "Text\n";

Closing a file

close(FILE);