File Coverage

blib/lib/Acme/CPANModules/GrepVariants.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Acme::CPANModules::GrepVariants;
2              
3 1     1   421246 use strict;
  1         2  
  1         53  
4 1     1   567 use Acme::CPANModulesUtil::Misc;
  1         491  
  1         148  
5              
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2025-08-20'; # DATE
8             our $DIST = 'Acme-CPANModules-GrepVariants'; # DIST
9             our $VERSION = '0.014'; # VERSION
10              
11             my $description = <<'MARKDOWN';
12             This list catalogs various grep-like tools.
13              
14             **1. Reimplementations**
15              
16             grep (from ) simply tries to reimplement grep in Perl, as
17             part of the project to reimplement many Unix utilities in Perl. It has few
18             practical uses; mainly educational. The portability advantage of Perl is
19             probably minor as grep and many Unix utilities are now available on other
20             platforms including Windows.
21              
22              
23             **2a. Improvements in recursive searching against files**
24              
25             . Created in 2005 by Andy Lester, is the granddaddy of
26             grep-like programs that try to improve the experience of using grep to search
27             for text in source code. ack skips VCS directories like `.git` or `.svn`, and
28             understands file types so it doesn't look into giant `.mp4`s and other binaries
29             by default. ack has spurred the development of its improvements (mostly in speed
30             aspect) like The Silver Searcher (`ag`) (implemented in C) or `ripgrep`
31             (implemented in Rust). `git` also now includes a `git-grep` utility (implemented
32             in C). ack has a website: . See also
33             .
34              
35             (from ) is a "grep clone using Perl regexp's with better
36             file filtering, defaults, speed, and presentation". It seems to focus on
37             providing many options to filter files (from including/excluding by file
38             extension, by matching against filename, by first line, by maximum directory
39             depth, and so on). It also offers some alternative output styles.
40              
41              
42             **2b. Improvements in searching for multiple patterns in no particular order**
43              
44             Normally with the regular grep, to search for all 'foo' and 'bar' *in no
45             particular order*, you either have to do something like:
46              
47             % grep --color=always foo FILES | grep bar
48              
49             or:
50              
51             % grep -P 'foo.*bar|bar.*foo' FILES
52              
53             both of which get unwieldy if the number of patterns get higher. Or you can use
54             look-ahead:
55              
56             % grep -P '(?=.*foo)(?=.*bar)' FILES
57              
58             but this does not capture (thus highlight) the patterns. To do that, you can
59             pipe to grep once more:
60              
61             % grep -P '(?=.*foo)(?=.*bar)' FILES | grep -P '(foo|bar)'
62              
63             but you introduce the complications of double filtering (e.g. filenames in
64             FILES is now the subject of the second grep).
65              
66             Note that searching for multiple patterns in particular order ('foo.*bar'), or
67             searching for aternates from multiple patterns ('foo|bar') is no problem in
68             grep.
69              
70             Some tools have been written to make it easier to specify multiple patterns:
71              
72             (from ) sports a `--all` option to require all
73             patterns to appear in a line (in no particular order). Normally, when multiple
74             patterns are given (via multiple `-e` or `--regexp` options), grep will include
75             lines that just contain at least one of the patterns.
76              
77             (from ). By default, greple only display lines
78             that contain all patterns, instead of just one. greple also has a few other
79             tricks up its sleeve, like configuration file to define complex regexes,
80             matching across lines, and Japanese text support.
81              
82             (from ) is a grep wrapper to convert
83             multiple terms into a chain of look-ahead patterns like described above. This
84             allows you to use the standard grep.
85              
86              
87             **3. Variants: alternate ways of specifying things to search for**
88              
89             Instead of specifying a regexp pattern directly, with (from
90             ) you can specify a pattern name in a ::*
91             module instead.
92              
93             With (from ) you can search using wildcard pattern
94             instead of regex, which is admittedly more limited than regex.
95              
96             (from lets you specify a
97             text and it will only show lines from input that are similar to the provided
98             text.
99              
100             (from lets you specify a
101             word and it will only show lines from input that have words that sound like the
102             provided word. You can choose from one of several phonetic algorithms like
103             Metaphone (the default), Soundex, etc.
104              
105             **4a. Variants: alternate source: repository (version control system) content and history**
106              
107             For git, the abovementioned `git-grep` can search for files in the work tree as
108             well as commit content. For Mercurial, `hg grep` accomplishes the same.
109             Alternatively you can dump the history then use the standard `grep` to go
110             through it.
111              
112              
113             **4b. Variants: alternate source: Perl source code**
114              
115             (from ) lets you grep over locally installed Perl
116             modules. It's basically a shortcut for something like this:
117              
118             % pmlist -Rx | xargs grep PAT
119             % grep PAT $(pmlist -Rx)
120              
121             (from ) is a CLI for web service
122             , which is no longer operating. To grep from files on
123             CPAN, use .
124              
125             (from ) uses to let you grep over Perl
126             *documents*; it allows you to do things like: search only in Perl code comments
127             or inside string literals.
128              
129             (from ) greps from POD sections of Perl source.
130              
131              
132             **4c. Variants: alternate source: CSV**
133              
134             (from )
135              
136             (from ) allows you to apply Perl code against
137             rows of CSV.
138              
139              
140             **4d. Variants: alternate source: word lists**
141              
142             (from ) greps words from wordlist modules
143             (modules that contains word lists, see WordList).
144              
145              
146             **4e. Variants: other alternate sources**
147              
148             (from ), with
149             as shorter alias.
150              
151             (from ).
152              
153             (from ).
154              
155             (from ).
156              
157             (from ).
158              
159             (from ).
160              
161             (alias: ) (from ) searches
162             against text in PDF files (it's a wrapper for `pdftotext` utility and grep).
163              
164             (from ) searches against table of contents of
165             tar files.
166              
167              
168             **5a. Variants: searching URLs**
169              
170             (from ) greps URLs from lines of input. You
171             don't have to manually specify regex that matches URLs yourself; you can just
172             add additional criteria for the URLs, e.g. whether the host part must contain
173             some text, or whether a certain query parameter must match some pattern.
174              
175              
176             **5b. Variants: searching dates**
177              
178             (from L) greps for dates in lines of text.
179              
180             (from L) prints lines matching a date range.
181              
182             MARKDOWN
183              
184             our $LIST = {
185             summary => 'List of grep-like CLI utilities available on CPAN',
186             description => $description,
187             entries => [
188             ],
189             };
190              
191             Acme::CPANModulesUtil::Misc::populate_entries_from_module_links_in_description;
192              
193             1;
194             # ABSTRACT: List of grep-like CLI utilities available on CPAN
195              
196             __END__