# Read the total content of a file. With or without '<' open(FIL,"<$filename") || die "Cannot open $filename for reading: $!"; my @data = ; close(FIL); # Read a file line by line. Again with or without '<' open(FIL,"<$filename") or die "Cannot open $filename for reading: $!"; while (my $data = ) { ## statements }; close(FIL); # Create a file and write a line of data. # NOTE: If the file already exists it will be OVERWRITTEN my $data = "A line of text"; open(FIL,">$filename") || die "Cannot create $filename for writing: $!"; print FILE "$data\n"; close(FIL); # Append a line of data to a file. Creates the file if it does not exist. open(FIL,">>$filename") || die "Cannot open $filename for appending: $!"; print FILE "$data\n"; close(FIL);