File Coverage

blib/lib/Acme/Test/Pr0n.pm
Criterion Covered Total %
statement 41 42 97.6
branch 8 14 57.1
condition 5 8 62.5
subroutine 7 8 87.5
pod 0 1 0.0
total 61 73 83.5


line stmt bran cond sub pod time code
1             package Acme::Test::Pr0n;
2              
3 1     1   28724 use 5.006;
  1         4  
  1         44  
4 1     1   5 use strict;
  1         2  
  1         41  
5 1     1   5 use warnings;
  1         8  
  1         41  
6 1     1   5 use Carp;
  1         2  
  1         112  
7              
8             our $VERSION = '0.01';
9              
10 1     1   5 use vars qw($AUTOLOAD);
  1         2  
  1         444  
11              
12             sub new {
13 1     1 0 17 my ($proto,$conf) = @_;
14 1   33     10 my $class = ref($proto) || $proto;
15 1         1 my $self = {};
16 1         4 bless($self,$class);
17              
18 1 50       5 croak "File not supplied" unless defined $conf->{'filename'};
19 1 50       40 croak "Could not read $conf->{filename}" unless -r $conf->{'filename'};
20              
21 1         6 $self->{'filename'} = $conf->{'filename'};
22              
23             # should use IO::File or something
24 1         4 local undef $/;
25 1 50       49 open(FH,$self->{'filename'}) or croak("Could not open file $!");
26 1         43 $self->{'file'} = ;
27 1         11 close(FH);
28              
29 1         3 return $self;
30             }
31              
32 0     0   0 sub DESTROY{}
33              
34             sub AUTOLOAD {
35 3     3   17 my $self = shift;
36 3   100     14 my $flags = shift || undef;
37 3         5 my $name = $AUTOLOAD;
38 3         22 $name =~ s/.*://;
39              
40 3         6 my $clean_string; # store file with all other chars removed
41             my $num;
42              
43 3 100 66     17 if($flags && $flags eq 'i') {
44 1         35 ($clean_string = $self->{'file'}) =~ s/([^$name]+)//gi;
45 1 50       5 if($clean_string) {
46 1         13 $num = ($clean_string =~ s/$name/x/gi);
47             }
48             } else {
49 2         102 ($clean_string = $self->{'file'}) =~ s/([^$name]+)//g;
50 2 50       7 if($clean_string) {
51 2         27 $num = ($clean_string =~ s/$name/x/g);
52             }
53             }
54              
55 3 50       10 return 0 unless $num;
56 3         21 return $num;
57             }
58              
59             1;
60             __END__