Subj : code fixed To : All From : tony summerfelt Date : Wed Jan 28 2004 02:17 pm here's the fixed code. this program trims the binkp log to however many days you specify: i don't need archiving, but i'm sure anyone here can add the code to archive the trimmed lines :) ========================================================================== 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() { $nl=$_ if ! /(\[\d+\])/; @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 defined($nl); print $trimmed $_ if $diff[0] < $ARGV[1] && defined(@diff); undef(@diff); undef($nl); } close binkd; open (binkd, ">$ARGV[0]") || die "can't open $ARGV[0] -- $!"; seek($trimmed,0,0); copy ($trimmed, $ARGV[0]) ========================================================================== --- GoldED/spleen 3.0.1-os1+ * Origin: ventedspleen.dyndns.org (1:261/38.5) .