Handling Files
To open a file, read it in, print it, and close it,
use the following scripts in this example:
Example:
--------
$file = 'any_file.txt'; # Name of the file
open(INFO, $file); # Open the file
@lines = ; # Read it into an array @lines
close(INFO); # Close the file
print @lines; # Print the array
To append to a file, use
open(INFO, ">>$file"); # Open for appending
Example:
-------
open(INFO, ">> $file");
print INFO "This line goes to the file.\n";
@lines = ; # Read it into an array @lines
close(INFO); # Close the file
print @lines; # Print the array
|