| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | binktrim.pl bugfix |
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 {at}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++;
{at}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()
{
{at}binkdate=split(" ");
{at}binktime=split(/:/,$binkdate[3]);
{at}binkdate=($year, $moy{$binkdate[2]}, $binkdate[1],
$binktime[0],$binktime[1],$binktime[2]);
{at}diff=Delta_DHMS({at}binkdate,{at}today) if /(\[\d+\])/;
print $trimmed $_ if $diff[0] < $ARGV[1] && defined({at}diff);
next if defined({at}diff);
print $trimmed $_ if ! /(\[\d+\])/;
undef({at}diff);
}
close binkd;
seek($trimmed,0,0);
copy ($trimmed, $ARGV[0])
##########################################################################
--- GoldED/spleen 3.0.1+
* Origin: ventedspleen.dyndns.org (1:249/100)SEEN-BY: 633/267 270 @PATH: 249/100 261/38 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.