(New to perl)
I’m trying to update an existing perl script to store in a file the last time that it was run, in order to do something “since” that date on the next run.
Is there a safe way to store this in a file that I can then read into a timestamp again?
I’ve found out how to write files
# Open for writing
open(MYFILE,">$filepath/$filename") || "> ERROR: Couldn't open file for writing\n";
print MYFILE $result;
close MYFILE;
And also how to get the time as a string
my ($sec, $min, $hour, $day, $mon, $year) = localtime();
$LAST_RUN_DATETIME=strftime( "%Y/%m/%d %T", $sec, $min, $hour, $day, $mon, $year);
Thanks for your time
I would write something like this probably:
and to read it in is just:
That timestamp will be in this form:
(day of the week) mmm (day of the month) hh:mm:ss yyyy