The open function opens a file or device and associates it with a filehandle.
It returns 1 upon success and undef otherwise.
# open a filehandle for reading:
open (SOURCE_FILE, "filename"); # or open (SOURCE_FILE, "<filename");
# open a filehandle for writing:
open (RESULT_FILE, ">filename");
# open a filehandle for appending:
open (LOGFILE, ">>filename";
# open a filehandle for both reading and writing:open (IN_OUT_FILE, "+>filename"); # or open (IN_OUT_FILE, "+<filename");# SOURCE_FILE, RESULT_FILE, LOGFILE and IN_OUT_FILE are examples of filehandle names.
my $in_file = "filename1";
open (SOURCE_FILE, "$in_file");
my $out_file = "filename2";
open (RESULT_FILE, ">$out_file");