line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#!/usr/bin/perl |
4
|
|
|
|
|
|
|
# -*- encoding: utf-8; mode: cperl -*- |
5
|
|
|
|
|
|
|
package POE::Filter::Regexp; |
6
|
1
|
|
|
1
|
|
640
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
310
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION='1.0'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my ($class,$re)=@_; |
13
|
0
|
|
0
|
|
|
|
$re ||= qr/\n/; |
14
|
0
|
0
|
|
|
|
|
die "Param in new must be a Regexp but this is a ".ref($re) unless ref $re eq 'Regexp'; |
15
|
0
|
|
|
|
|
|
return bless [ |
16
|
|
|
|
|
|
|
'', # raw unparsed data |
17
|
|
|
|
|
|
|
$re, |
18
|
|
|
|
|
|
|
], $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $stream) = @_; |
24
|
0
|
|
|
|
|
|
my @ret; |
25
|
0
|
|
|
|
|
|
while($_=shift @$stream){ |
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) { |
30
|
0
|
0
|
|
|
|
|
next unless $-[0]; #begin of stream |
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; |
42
|
|
|
|
|
|
|
__END__ |