| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | code fixed |
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 {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()
{
$nl=$_ if ! /(\[\d+\])/;
{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 defined($nl);
print $trimmed $_ if $diff[0] < $ARGV[1] && defined({at}diff);
undef({at}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)SEEN-BY: 633/267 270 @PATH: 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™.