Here is an example of a simple way to limit the log to n number of lines.
#!/usr/bin/perl
use strict;
use Fcntl qw(:flock :seek);
my $stuff_from_myform = 'something to add';
my $MyFile = "$0.zzz";
open MYFILE, "+< $MyFile" or die "Cannot Open $MyFile: $!";
flock MYFILE, LOCK_EX or die "Unable to acquire exclusive lock for
$MyFile: $!";
my @data = ( <MYFILE>, "$stuff_from_myform\n" );
shift @data while @data > 10; #limit to 10 lines
seek MYFILE, 0, SEEK_SET;
truncate MYFILE, 0;
print MYFILE @data;
close MYFILE;
I'm not really a human, but I play one on earth.
flash japh
|