line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Author Chris "BinGOs" Williams |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This module may be used, modified, and distributed under the same |
4
|
|
|
|
|
|
|
# terms as Perl itself. Please see the license that came with your Perl |
5
|
|
|
|
|
|
|
# distribution for details. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package POE::Filter::ParseWords; |
9
|
|
|
|
|
|
|
$POE::Filter::ParseWords::VERSION = '1.08'; |
10
|
|
|
|
|
|
|
#ABSTRACT: A POE-based parser to parse text into an array of tokens. |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
12879
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
13
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
14
|
1
|
|
|
1
|
|
3
|
use base qw(POE::Filter); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
431
|
|
15
|
1
|
|
|
1
|
|
757
|
use Text::ParseWords; |
|
1
|
|
|
|
|
879
|
|
|
1
|
|
|
|
|
283
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
8
|
my $class = shift; |
19
|
1
|
|
|
|
|
2
|
my %opts = @_; |
20
|
1
|
|
|
|
|
3
|
$opts{lc $_} = delete $opts{$_} for keys %opts; |
21
|
1
|
50
|
|
|
|
4
|
$opts{keep} = 0 unless $opts{keep}; |
22
|
1
|
50
|
|
|
|
4
|
$opts{delim} = '\s+' unless $opts{delim}; |
23
|
1
|
|
|
|
|
3
|
$opts{BUFFER} = []; |
24
|
1
|
|
|
|
|
21
|
bless \%opts, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get { |
28
|
2
|
|
|
2
|
1
|
1083
|
my ($self, $raw) = @_; |
29
|
2
|
|
|
|
|
2
|
my $events = []; |
30
|
2
|
|
|
|
|
9
|
push @$events, [ parse_line( $self->{delim}, $self->{keep}, $_ ) ] for @$raw; |
31
|
2
|
|
|
|
|
210
|
return $events; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_one_start { |
35
|
0
|
|
|
0
|
1
|
0
|
my ($self, $raw) = @_; |
36
|
0
|
|
|
|
|
0
|
push @{ $self->{BUFFER} }, $_ for @$raw; |
|
0
|
|
|
|
|
0
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_one { |
40
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
41
|
0
|
|
|
|
|
0
|
my $events = []; |
42
|
0
|
|
|
|
|
0
|
my $event = shift @{ $self->{BUFFER} }; |
|
0
|
|
|
|
|
0
|
|
43
|
0
|
0
|
|
|
|
0
|
push @$events, [ parse_line( $self->{delim}, $self->{keep}, $event ) ] if defined $event; |
44
|
0
|
|
|
|
|
0
|
return $events; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub put { |
48
|
0
|
|
|
0
|
1
|
0
|
warn "PUT is unimplemented\n"; |
49
|
0
|
|
|
|
|
0
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub clone { |
53
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
54
|
1
|
|
|
|
|
2
|
my $nself = { }; |
55
|
1
|
|
|
|
|
1
|
$nself->{$_} = $self->{$_} for keys %{ $self }; |
|
1
|
|
|
|
|
9
|
|
56
|
1
|
|
|
|
|
3
|
$nself->{BUFFER} = [ ]; |
57
|
1
|
|
|
|
|
3
|
return bless $nself, ref $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
qq[Parse it!]; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |