Fri Jan 11 12:41:32 2008mark.zealey [...] pipex.net - Ticket created
Subject:
tell() implimentation
You can create a tell() implimentation for File::Tail using the
following sub:
sub tell {
my $self = shift;
$self->{endpos} - length( $self->{buffer} );
}
Fri Jan 11 14:55:08 2008matija+pause [...] serverflow.com - Correspondence added
From:
matija+pause [...] serverflow.com
On Fri Jan 11 12:41:32 2008, mark.zealey@pipex.net wrote:
Show quoted text
> You can create a tell() implimentation for File::Tail
That is true, but I don't see the point. I'm not going to be providing
the seek, so what use is a tell?
Fri Jan 11 14:55:09 2008The RT System itself - Status changed from 'new' to 'open'
Mon Jan 14 04:16:52 2008mark.zealey [...] pipex.net - Correspondence added
Subject:
RE: [rt.cpan.org #32255] tell() implimentation
Date:
Mon, 14 Jan 2008 09:15:23 -0000
To:
<bug-File-Tail [...] rt.cpan.org>
From:
"Mark Zealey" <mark.zealey [...] pipex.net>
In this case, I need a tail() implimentation because I've got a
File::Tail process going which basically indexes a logfile, but to save
on space it doesn't store the contents of the line, only the keywords.
Therefore, I want to store an offset to which I can seek() at some point
in the future and retrieve the full line. I could keep some line counter
inside my program, but tell() seems the best way to solve this problem.
Mark
Tue Jan 22 05:51:49 2008mark.zealey [...] pipex.net - Correspondence added
From:
mark.zealey [...] pipex.net
Apologies; should more correctly read:
sub tell {
my $self = shift;
$self->{curpos} - length( $self->{buffer} );
}
By the way, I also discovered we need a seek implementation so we can
resume tailing from the point at which we left off last time. The below
works (only for SEEK_SET though):
sub seek {
my ($self, $position) = @_;
# Set the start pointer to the correct position
$self->{curpos} = sysseek $self->{handle}, $position, $self->SEEK_SET;
# Nuke the buffer
$self->{buffer} = '';
}