line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
App::Greple::xp - extended pattern module |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Version 0.01 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
greple -Mxp |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This module provides functions can be used by B pattern and |
16
|
|
|
|
|
|
|
region options. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 OPTIONS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over 7 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item B<--le-file> I |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item B<--inside-file> I |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item B<--outside-file> I |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item B<--include-file> I |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item B<--exclude-file> I |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Read file contents and use each lines as a pattern for options. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Lines start with hash mark (C<#>) is ignored as a comment line. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
String after double slash (C/>) is also ignored. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Because file name is globbed, you can use wild card to give multiple |
39
|
|
|
|
|
|
|
files. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$ greple -Mxp --exclude-file '*.exclude' ... |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Kazumasa Utashiro |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 LICENSE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Copyright 2019- Kazumasa Utashiro. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
60
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package App::Greple::xp; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
846
|
use v5.14; |
|
1
|
|
|
|
|
4
|
|
68
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
69
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
74
|
|
|
|
|
|
|
our @EXPORT = qw(&xp_pattern_file); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
1
|
|
650
|
use open IO => ':utf8'; |
|
1
|
|
|
|
|
1303
|
|
|
1
|
|
|
|
|
6
|
|
77
|
1
|
|
|
1
|
|
617
|
use App::Greple::Common; |
|
1
|
|
|
|
|
371
|
|
|
1
|
|
|
|
|
178
|
|
78
|
1
|
|
|
1
|
|
497
|
use App::Greple::Regions qw(match_regions merge_regions); |
|
1
|
|
|
|
|
10598
|
|
|
1
|
|
|
|
|
61
|
|
79
|
1
|
|
|
1
|
|
12
|
use Data::Dumper; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
377
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
our $opt_hash_comment = 1; |
82
|
|
|
|
|
|
|
our $opt_slash_comment = 0; |
83
|
|
|
|
|
|
|
our $opt_glob = 1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub xp_pattern_file { |
86
|
0
|
|
|
0
|
0
|
|
my %arg = @_; |
87
|
0
|
0
|
|
|
|
|
my $target = delete $arg{&FILELABEL} or die; |
88
|
0
|
|
|
|
|
|
my $file = $arg{file}; |
89
|
0
|
0
|
|
|
|
|
my @files = $opt_glob ? glob $file : ($file); |
90
|
0
|
|
|
|
|
|
my @r; |
91
|
0
|
|
|
|
|
|
for my $file (@files) { |
92
|
0
|
0
|
|
|
|
|
open my $fh, $file or die "$file: $!"; |
93
|
0
|
|
|
|
|
|
while (my $p = <$fh>) { |
94
|
0
|
|
|
|
|
|
chomp $p; |
95
|
0
|
0
|
|
|
|
|
if ($opt_hash_comment) { |
96
|
0
|
0
|
|
|
|
|
next if $p =~ /^\s*#/; |
97
|
|
|
|
|
|
|
} |
98
|
0
|
0
|
|
|
|
|
if ($opt_slash_comment) { |
99
|
0
|
|
|
|
|
|
$p =~ s{//.*}{}; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
0
|
|
|
|
|
next unless $p =~ /\S/; |
102
|
0
|
|
|
|
|
|
push @r, match_regions pattern => qr/$p/m; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
|
merge_regions @r; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__DATA__ |