Hi,

I've found myself writing the same script again and again for a client.

Given a set of log files, if such and such field match such and such
condition, then process them in a certain way. I've put the logic
in a module, and I'm now looking for a name for it. I'd also like
to know if this module looks useful to others (it was to me, since it
allowed me to write a CGI that "grepped" through numerous log files
and returned a subset of them as an HTML or CSV file).

The module works like this:

    use Blah;    # not a very good name for CPAN :-)

    my $blah = Blah->new(
        delimiter => ':',
        fields    => [qw( bap clank glipp plop )],
        show      => \&show_my_data,
    );

    # quelques infos utiles
    $blah->add_filter(
        bap   => 'eq "zlopp"',
        clank => '!~ /clunk_eth/',
    );
    $blah->add_file( glob "*.log" );

    $blah->run;

When the run() method is called, the object compute a piece of Perl
code which is then eval()ed (with a localised @ARGV). The computed
code is the following (note the use of arrays for the selection pass
and of a hash for the processing):

    while(<>) {
        chomp;
        my @data = split qr{:};
        if(    ( $data[1] !~ /clunk_eth/ )
            && ( $data[0] eq "zlopp" ) )
        {
            my %data;
            @data{qw(bap clank glipp plop)} = @data;
            $self->{show}->(\%data);
        }
    }

In future versions, I may add support for regular expressions for
parsing the fields (thus allowing a nice connection with my other module
Regexp::Log), the possibility to keep using an array for processing,
and have a better interface to add conditions (this is very crude,
and open to attacks if people using this module are not very careful).

I haven't been very successful in finding a name for this module.
Sébastien Aperghis-Tramoni proposed Log::Process, but maybe a name
like Log::Processor would be better.

Any other name ideas or comments about the module and its interface?

-- 
 Philippe "BooK" Bruhat

 The greatest monster of them all is ignorance.
                             (Moral to Pal'n Drumm Storry in Groo #89 (Epic))

Reply via email to