| 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/
MC/DC0%0/1
$re ||= qr/\n/
$re
Truth table0%0/2
A
A= $re
| |||||||||||||
| 14 | 0 | ▶ | die "Param in new must be a Regexp but this is a ".ref($re) unless ref $re eq 'Regexp'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 30 | 0 | ▶ | next unless $-[0]; #begin of stream | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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__ | ||||||||||||