$VERSION =~ s/^\D*(\d+).*/r$1/;
}
-our $FILEINFO;
+our $FileInfo;
our $PURGE_LOGS = 0;
print STDERR $/, __FILE__, ': $Id$' if ($::DEBUG);
if (!get_config ('input'))
{
+ # TODO: Make a complete (!) lsit..
print STDERR <<EOF;
Usage: $0 [options] <logfile> [logfile logfile ..]
require "Onis/Parser/$logtype.pm";
require Onis::Parser::Persistent;
require Onis::Data::Persistent;
-import Onis::Parser qw/parse last_date/;
-import Onis::Parser::Persistent qw#newfile#;
-import Onis::Data::Persistent qw#init#;
+import Onis::Parser (qw(parse last_date));
+import Onis::Parser::Persistent (qw(newfile));
+import Onis::Data::Persistent ();
-$FILEINFO = init ('$FILEINFO', 'hash');
+$FileInfo = Onis::Data::Persistent->new ('FileInfo', 'inode', qw(mtime));
if (get_config ('purge_logs'))
{
}
else
{
+ my ($old_mtime) = $FileInfo->get ($inode);
+
print STDERR $/, __FILE__, ": ``$file'': " if ($::DEBUG & 0x200);
- if (defined ($FILEINFO->{$inode}{'mtime'}))
+
+ if (defined ($old_mtime))
{
- if ($FILEINFO->{$inode}{'mtime'} == $mtime)
+ if ($old_mtime == $mtime)
{
print STDERR "File did not change. Skipping." if ($::DEBUG & 0x200);
next;
}
- elsif ($FILEINFO->{$inode}{'mtime'} < $mtime)
+ elsif ($old_mtime < $mtime)
{
print STDERR "File changed. Reading it again." if ($::DEBUG & 0x200);
}
{
print STDERR "File appears to be new. Reading it." if ($::DEBUG & 0x200);
}
- $FILEINFO->{$inode}{'mtime'} = $mtime;
+ $FileInfo->put ($inode, $mtime);
}
# truncate
}
}
- newfile ($FILEINFO->{$inode});
+ newfile ($FileInfo->{$inode});
while (<$logfile>)
{
s/\n|\r//g;
{
print STDERR $/, __FILE__, ": Unable to delete empty file ``$file'': $!";
}
- delete ($FILEINFO->{$inode});
+ delete ($FileInfo->{$inode});
}
else
{