line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pipe::Tube::Grep; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
80
|
|
3
|
1
|
|
|
1
|
|
15
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
15
|
use 5.006; |
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base 'Pipe::Tube'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
283
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
2
|
|
|
2
|
0
|
5
|
my ($self, $expr) = @_; |
12
|
2
|
|
|
|
|
9
|
$self->logger("Receiving the grep expression: $expr"); |
13
|
2
|
|
|
|
|
4
|
$self->{expr} = $expr; |
14
|
2
|
|
|
|
|
5
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub run { |
18
|
14
|
|
|
14
|
0
|
26
|
my ($self, @input) = @_; |
19
|
|
|
|
|
|
|
|
20
|
14
|
|
|
|
|
40
|
$self->logger("The grep expression: $self->{expr}"); |
21
|
14
|
100
|
|
|
|
31
|
if ("Regexp" eq ref $self->{expr}) { |
22
|
7
|
|
|
|
|
36
|
return grep /$self->{expr}/, @input; |
23
|
|
|
|
|
|
|
} else { |
24
|
7
|
|
|
|
|
10
|
my $sub = $self->{expr}; |
25
|
7
|
|
|
|
|
12
|
return grep { $sub->($_) } @input; |
|
5
|
|
|
|
|
10
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|