Opening a File
-
To read or write to a file, you must first open it.
-
Four things to do:
-
Use the open keyword.
-
Assign a file handle, which acts as an alias for the file.
-
Use the alias to open, close, and write to the file.
-
Determine read, write, append.
-
read: <
-
write (overwrite existing contents): >
-
append (do not overwrite existing contents): >>
-
Give the name and location of the file.
open(FILEHANDLE, "RWFLAGFILENAME");
open(DATA, ">>../userdata.txt");
Verifying that a file opened
Home