NAME

Log::Procmail - Perl extension for reading procmail logfiles.

SYNOPSIS

use Log::Procmail;

my $log = new Log::Procmail 'procmail.log';

# loop on every abstract
while(my $rec = $log->next) {
    # do something with $rec->folder, $rec->size, etc.
}

DESCRIPTION

Log::Procmail reads procmail(1) logfiles and returns the abstracts one by one.

$log = Log::Procmail->new( @files );

Constructor for the procmail log reader. Returns a reference to a Log::Procmail object.

The constructor accepts a list of file as parameter. This allows you to read records from several files in a row:

$log = Log::Procmail->new( "$ENV{HOME}/.procmail/log.2",
                           "$ENV{HOME}/.procmail/log.1",
                           "$ENV{HOME}/.procmail/log", );

When $log reaches the end of the file "log", it doesn't close the file. So, after procmail processes some incoming mail, the next call to next() will return the new records.

$rec = $log->next

Return a Log::Procmail::Abstract object that represent an entry in the log file. Return undef if there is no record left in the file.

When the Log::Procmail object reaches the end of a file, and this file is not the last of the stack, it closes the current file and opens the next one.

When it reaches the end of the last file, the file is not closed. Next time the record method is called, it will check again in case new abstracts were appended.

Procmail(1) log look like the following:

From karen644552@btinternet.com  Fri Feb  8 20:37:24 2002
 Subject: Stock Market Volatility Beating You Up? (18@2)
  Folder: /var/spool/mail/book						   2840
$log->push( $file [, $file2 ...] );

Push one or more files on top of the list of log files to examine. When Log::Procmail runs out of abstracts to return (i.e. it reaches the end of the file), it transparently opens the next file (if there is one) and keeps returning abstracts.

$log->errors( [bool] );

Set or get the error flag. If set, when the next() method will return the string found in the log file, instead of ignoring it. Be careful: it is a simple string, not a Log::Procmail::Abstract object.

Default is to return no error.

Log::Procmail::Abstract

Log::Procmail::Abstract is a class that hold the abstract information. Since the abstract hold From, Date, Subject, Folder and Size information, all this can be accessed and modified through the from(), date(), subject(), folder() and size() methods.

Log::Procmail::next() returns a Log::Procmail::Abstract object.

Log::Procmail::Abstract accessors

The Log::Procmail::Abstract object accessors are named from(), date(), subject(), folder() and size(). They return the relevant information when called without argument, and set it to their first argument otherwise.

# count mail received per folder
while( $rec = $log->next ) { $folder{ $rec->folder }++ }
$rec->ymd()

Return the date in the form yyyymmmddhhmmss where each field is what you think it is. ;-) This method is read-only.

TODO

The Log::Procmail object should be able to read from STDIN.

BUGS

The ymd() method should be smarter.

Please report all bugs through the rt.cpan.org interface:

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Procmail

AUTHOR

Philippe "BooK" Bruhat <book@cpan.org>.

Thanks to Briac "Oeufmayo" Pilpré and David "Sniper" Rigaudiere for early comments on irc. Many thanks to Michael Schwern for insisting so much on the importance of tests and documentation.

Many thanks to "Les Mongueurs de Perl" for making cvs.mongueurs.net available for Log-Procmail and many other projects.

COPYRIGHT

Copyright (c) 2002, Philippe Bruhat. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)

SEE ALSO

perl(1), procmail(1).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 301:

Non-ASCII character seen before =encoding in 'Pilpré'. Assuming CP1252