[RFC] File::Rotate - read from rotating logfiles

From: Mark Lawrence (nomad_at_null.net)
Date: 11/29/04


Date: 29 Nov 2004 06:29:02 -0800

Hi,

I've written a module which might be useful by others. Comments and a
better name are welcome.

Regards,
Mark.

NAME
       File::Rotate - read from rotating logfiles

SYNOPSIS
         use File::Rotate;
         my $fh = new File::Rotate(file => $file,
                                   statefile => $statefile);
         die unless($fh);

         while (my $line = $fh->getline) {
             # do something with $line
         }

DESCRIPTION
       File::Rotate allows you to easily read from files such as those
       produced by syslog(8) without the hassle of worrying about file
       rotation or compression. File rotation is automatically
       detected. This module would typically be used by programs
       called at regular intervals from cron(8).

METHODS
       new( file => $file, statefile => $statefile)

       Creates a "File::Rotate" object representing the file $file
       initialised with the state stored in $statefile. If $statefile
       does not exist it will be created and the file pointer will be
       set to zero (start of $file). If $statefile is a valid
       statefile for $file the file pointer will be moved to the last
       read position (in either $file or a rotated and/or compressed
       $file).

       $fh->getline( )

       Will return the next string from $file, or from the rotated
       version of $file. When the end of the rotated file is reached
       lines will be returned from the current $file. When the last
       file is reached 'undef' will be returned.

       $fh->save_state( )

       Save the current file pointer position to $statefile.

SEE ALSO
       IO::File