Lemonolap::Filter4lemon - Perl extension for lemonolap datawarehouse


Lemonolap-Wrapperolap documentation Contained in the Lemonolap-Wrapperolap distribution.

Index


Code Index:

NAME

Top

Lemonolap::Filter4lemon - Perl extension for lemonolap datawarehouse =head1 SYNOPSIS

use Lemonolap::Filter4lemon; Lemonolap::Filter4lemon->apply ('infile' => 'phase1.log', 'outfile'=> 'phase2.log', 'header' => 1);

This module is not used directly , you must use Lemonolap::filter4lemon which is a wrapper (Lemonolap::Wrapperolap).

  see man's pages Lemonolap::Wrapperolap 

  





DESCRIPTION

Top

  This module is a logs filter . It parses lemonldap logs issued form Lemonolap::Formatlog .
  It deletes  incompled lines and set the second of time at '00'

EXPORT

None by default.

Methods

apply ('infile' => 'phase1.log', 'outfile'=> 'phase2.log', 'header' => 1);

 


 Sends on output file  the  filtered file
 if 'header'  is true the first line is inchanged (colomns heads)  




SEE ALSO

Top

Lemonldap http://lemonldap.sourceforge.net/

Lemonolap http://lemonolap.sourceforge.net/

Lemonolap::Log4lemon

Lemonolap::Filter4lemon

Lemonolap::Wrapperolap

COPYRIGHT AND LICENSE

Top


Lemonolap-Wrapperolap documentation Contained in the Lemonolap-Wrapperolap distribution.

package Lemonolap::Filter4lemon;

use strict;
our $VERSION = '0.02';


# Preloaded methods go here.
sub new {
my $class =shift;
my %args = @_;
my $self;
$self=\%args;;
bless $self,$class;
return $self;
}

sub set_output {
	my $self =shift;
	$self->{file_out} = shift;
       return 1;
}       

sub apply {
my $self =shift;
my %args = @_;
my $file_in = $args{infile};
my $file_out = $args{outfile};
$self->{file_in} =$file_in;
$self->{file_out} =$file_out;
$self->{header} =$args{header};
my $FILE ;
my $FILEOUT;
open ( $FILE,"< $file_in") || die "$file_in $!\n";
open ( $FILEOUT,"> $file_out") || die "$file_out $!\n";
my %vhost;
my $line;
if ($self->{header} ) {
$line = readline($FILE);
chomp($line);
}


while (my $l = <$FILE>) {
	chomp($l);
    my @tab = split /\|/,$l;
$vhost{$tab[9]}++;

} 
close $FILE;
foreach (keys %vhost) {
delete $vhost{$_}  if $vhost{$_} < 10;

}
open ( $FILE,"< $file_in") || die "$file_in $!\n";
if ($self->{header} ) {
$line = readline($FILE);
chomp($line);
print $FILEOUT  "$line\n"; 
}
while (my $l =  <$FILE>) {
	chomp($l);
    my @tab = split /\|/ ,$l;
next unless $vhost{$tab[9]};
substr($tab[1],4,2) = "00";
my $l =join '|' ,@tab; 
print $FILEOUT "$l\n";
} 
close $FILE;
close $FILEOUT;

return 1 ;

}


1;
__END__