line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tail::Tool::Plugin::Replace; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2010-11-10 09:10:52 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2013
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
31
|
|
10
|
2
|
|
|
2
|
|
13700
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
11
|
2
|
|
|
2
|
|
13
|
use version; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
12
|
2
|
|
|
2
|
|
146
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
143
|
|
13
|
2
|
|
|
2
|
|
12
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
24
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'Tail::Tool::PreProcess'; |
16
|
|
|
|
|
|
|
with 'Tail::Tool::RegexList'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = version->new('0.4.8'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub process { |
21
|
2
|
|
|
2
|
1
|
1118
|
my ($self, $line) = @_; |
22
|
2
|
|
|
|
|
4
|
my $matches; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
4
|
for my $match ( @{ $self->regex } ) { |
|
2
|
|
|
|
|
67
|
|
25
|
2
|
|
|
|
|
55
|
$matches += $match->enabled; |
26
|
2
|
50
|
|
|
|
48
|
if ( $match->enabled ) { |
27
|
2
|
|
|
|
|
50
|
my $reg = $match->regex; |
28
|
2
|
|
|
|
|
51
|
my $rep = $match->replace; |
29
|
2
|
|
|
|
|
4
|
eval { $line =~ s/$reg/eval qq{"$rep"}/e }; |
|
2
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
57
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# return empty array if there were enabled matches else return the line |
34
|
2
|
|
|
|
|
24
|
return ($line); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _set_regex { |
38
|
0
|
|
|
0
|
|
|
my ( $self, $regexs, $old_regexs ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
for my $regex ( @{ $regexs } ) { |
|
0
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
$regex->replace('') if !$regex->has_replace; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Tail::Tool::Plugin::Replace - <One-line description of module's purpose> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This documentation refers to Tail::Tool::Plugin::Replace version 0.4.8. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use Tail::Tool::Plugin::Replace; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Brief but working code example(s) here showing the most common usage(s) |
65
|
|
|
|
|
|
|
# This section will be as far as many users bother reading, so make it as |
66
|
|
|
|
|
|
|
# educational and exemplary as possible. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
A full description of the module and its features. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
May include numerous subsections (i.e., =head2, =head3, etc.). |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C<process ($line)> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Param: C<$line> -The line to process |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Performs any changes to the line that have been specified. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
A list of every error and warning message that the module can generate (even |
87
|
|
|
|
|
|
|
the ones that will "never happen"), with a full explanation of each problem, |
88
|
|
|
|
|
|
|
one or more likely causes, and any suggested remedies. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
A full explanation of any configuration system(s) used by the module, including |
93
|
|
|
|
|
|
|
the names and locations of any configuration files, and the meaning of any |
94
|
|
|
|
|
|
|
environment variables or properties that can be set. These descriptions must |
95
|
|
|
|
|
|
|
also include details of any configuration language used. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
A list of all of the other modules that this module relies upon, including any |
100
|
|
|
|
|
|
|
restrictions on versions, and an indication of whether these required modules |
101
|
|
|
|
|
|
|
are part of the standard Perl distribution, part of the module's distribution, |
102
|
|
|
|
|
|
|
or must be installed separately. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
A list of any modules that this module cannot be used in conjunction with. |
107
|
|
|
|
|
|
|
This may be due to name conflicts in the interface, or competition for system |
108
|
|
|
|
|
|
|
or program resources, or due to internal limitations of Perl (for example, many |
109
|
|
|
|
|
|
|
modules that use source code filters are mutually incompatible). |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
A list of known problems with the module, together with some indication of |
114
|
|
|
|
|
|
|
whether they are likely to be fixed in an upcoming release. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Also, a list of restrictions on the features the module does provide: data types |
117
|
|
|
|
|
|
|
that cannot be handled, performance issues and the circumstances in which they |
118
|
|
|
|
|
|
|
may arise, practical limitations on the size of data sets, special cases that |
119
|
|
|
|
|
|
|
are not (yet) handled, etc. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The initial template usually just has: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
There are no known bugs in this module. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Patches are welcome. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Copyright (c) 2010 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW, Australia). |
136
|
|
|
|
|
|
|
All rights reserved. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
139
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
140
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
141
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
142
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |