Perl: Appending to a File
Appending to a File
open(LOGFILE,">>log.txt"); # Open log.txt for writing
print LOGFILE "$date - $user\n"; # Adds entry to the log file
close(LOGFILE); # close the filehandle
- Opening a file for appending will create the file if it does not exist
- Lines are added to the end of the file as they are written