Perl: Writing to a File
Writing to a File
open(LOGFILE,">log.txt"); # Open log.txt for writing
$date = `date`; # Get today's date from the system
print LOGFILE "$date - $user\n"; # Write an entry to the log file
close(LOGFILE); # close the filehandle
- Opening a file for writing will overwrite the file if it already exists