blib/lib/POE/Filter/Regexp.pm

filter: Statementstmt 32.0% 8 / 25 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 23.8% 10 / 42 CC 6 SCAR 25.7
CC
6
Cov
23%
get
20.0
new
12.0
BEGIN
1.0
CRAP 13.1
↑ Summary
1  
2  
3 #!/usr/bin/perl
4 # -*- encoding: utf-8; mode: cperl -*-
5 package POE::Filter::Regexp;
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $VERSION='1.0';
10  
11 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
12 0 my ($class,$re)=@_;
13 0 ▶ $re ||= qr/\n/;
Condition0%0/2
$re ||= qr/\n/
l!l
00
MC/DC0%0/1
$re ||= qr/\n/
$re
Truth table0%0/2
A
A= $re
Aresult
11
00
14 0 ▶ die "Param in new must be a Regexp but this is a ".ref($re) unless ref $re eq 'Regexp';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $re eq "Regexp" 0 0 0
15 0 return bless [
16 '', # raw unparsed data
17 $re,
18 ], $class;
19 }
20  
21  
22 0 ▶sub get {
Subroutine get: not called CC=4 SCAR=30.0
Pod undocumented
23 0 my ($self, $stream) = @_;
24 0 my @ret;
25 0 ▶ while($_=shift @$stream){
Branch: 1 branch
BranchTrueFalseTotal
if ($_ = shift @$stream) 0 0 0
26 0 $self->[0].=$_;
27 0 $_=''; #yah we'r cl'r mems !!!111
28 0 my $p=0;
29 0 ▶ while($self->[0]=~/$self->[1]/gm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[0] =~ /$self->[1]/gm) 0 0 0
30 0 ▶ next unless $-[0]; #begin of stream
Branch: 1 branch
BranchTrueFalseTotal
unless $-[0] 0 0 0
31 0 push @ret, substr($self->[0], $p, $-[0]-$p);
32 0 $p=$-[0];
33 }
34 0 substr($self->[0], 0, $p)='';
35 }
36 0 $self->[0]=''.$self->[0]; #Clean holes in string.
37 0 return \@ret;
38 }
39  
40  
41 1 1;
42 __END__
↑ Summary