Filter4lemon.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 78 CC 5 SCAR 29.7
CC
5
Cov
0%
apply
30.0
new
2.0
set_output
2.0
CRAP 19.5
1 package Lemonolap::Filter4lemon;
2  
3 use strict;
4 our $VERSION = '0.02';
5  
6  
7 # Preloaded methods go here.
8 sub new {
9 my $class =shift;
10 my %args = @_;
11 my $self;
12 $self=\%args;;
13 bless $self,$class;
14 return $self;
15 }
16  
17 sub set_output {
18 my $self =shift;
19 $self->{file_out} = shift;
20 return 1;
21 }
22  
23 sub apply {
24 my $self =shift;
25 my %args = @_;
26 my $file_in = $args{infile};
27 my $file_out = $args{outfile};
28 $self->{file_in} =$file_in;
29 $self->{file_out} =$file_out;
30 $self->{header} =$args{header};
31 my $FILE ;
32 my $FILEOUT;
33 open ( $FILE,"< $file_in") || die "$file_in $!\n";
34 open ( $FILEOUT,"> $file_out") || die "$file_out $!\n";
35 my %vhost;
36 my $line;
37 if ($self->{header} ) {
38 $line = readline($FILE);
39 chomp($line);
40 }
41  
42  
43 while (my $l = <$FILE>) {
44 chomp($l);
45 my @tab = split /\|/,$l;
46 $vhost{$tab[9]}++;
47  
48 }
49 close $FILE;
50 foreach (keys %vhost) {
51 delete $vhost{$_} if $vhost{$_} < 10;
52  
53 }
54 open ( $FILE,"< $file_in") || die "$file_in $!\n";
55 if ($self->{header} ) {
56 $line = readline($FILE);
57 chomp($line);
58 print $FILEOUT "$line\n";
59 }
60 while (my $l = <$FILE>) {
61 chomp($l);
62 my @tab = split /\|/ ,$l;
63 next unless $vhost{$tab[9]};
64 substr($tab[1],4,2) = "00";
65 my $l =join '|' ,@tab;
66 print $FILEOUT "$l\n";
67 }
68 close $FILE;
69 close $FILEOUT;
70  
71 return 1 ;
72  
73 }
74  
75  
76 1;
77 __END__