Subj : binktrim.pl bugfix To : All From : tony summerfelt Date : Wed Mar 24 2004 01:00 pm gah, i had a config problem so i've been out of touch with this echo :/ anybody who's been using the perl version of the binkp log trimming program will have noticed an annoying bug...it padded the beginning of the file with all the blank lines from the last trim session... this is the fixed version: ########################################################################## use Date::Calc qw(Delta_DHMS); use IO::File; use File::Copy; die "usage: binktrim \n" unless @ARGV==2; %moy = ('Jan',1,'Feb',2,'Mar',3,'Apr',4,'May',5,'Jun',6, 'Jul',7,'Aug',8,'Sep',9,'Oct',10,'Nov',11,'Dec',12); ($sec,$min,$hour,$date,$moy,$year,$dow,$doy,$dst)=localtime(time); $year+=1900; $moy++; @today=($year, $moy, $date, $hour, $min, $sec); open (binkd, $ARGV[0]) || die "can't open $ARGV[0] -- $!"; $trimmed=IO::File->new_tmpfile || die "unable to create tmp file -- $!"; while() { @binkdate=split(" "); @binktime=split(/:/,$binkdate[3]); @binkdate=($year, $moy{$binkdate[2]}, $binkdate[1], $binktime[0],$binktime[1],$binktime[2]); @diff=Delta_DHMS(@binkdate,@today) if /(\[\d+\])/; print $trimmed $_ if $diff[0] < $ARGV[1] && defined(@diff); next if defined(@diff); print $trimmed $_ if ! /(\[\d+\])/; undef(@diff); } close binkd; seek($trimmed,0,0); copy ($trimmed, $ARGV[0]) ########################################################################## --- GoldED/spleen 3.0.1+ * Origin: ventedspleen.dyndns.org (1:249/100) .