On 11-11-23 03:31 PM, Mark Wagner wrote:
That would work, but it would introduce the need to periodically prune
the file, and would make reading the file much more complicated: if
the disk fills up, the final line could well be a fractional
timestamp, so I'd need to verify that what I'd just read was valid.

Use a rotating log file. This one rotates every week:


sub log_status {
  use POSIX;
  my $file = strftime( 'status-%w-%a.txt', localtime );
  open my $fh, '>>', $file or die "could not open $file: $!\n";
  for my $status ( @_ ){
    print $fh "$status\n" or die "could not print to $file: $!\n";
  }
  close $fh or die "could not close $file: $!\n";
}



--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

Never give up your dreams.  Give up your goals, plans,
strategy, tactics, and anything that's not working but never
give up your dreams.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to