June 2005
Beginner
480 pages
10h 31m
English
To write data to a file, you must first have a filehandle open for writing. Up till now, all open statements you have seen have opened the filehandle for reading only. The syntax for opening a file for writing is almost identical to that for reading:
open(filehandle, ">pathname") open(filehandle, ">>pathname")
The first syntax line should look familiar, except for the > in front of the pathname. The > signifies to Perl that the file specified at pathname should be overwritten with new data, that any existing data should be discarded, and that filehandle is open for writing. In the second example, >> tells Perl to open the file for writing but, if the file already exists, not to discard the contents but to append the new data to the ...
Read now
Unlock full access