It's definitely alpha code, but I've just released App::Pgrep. This installs pgrep on your machine. It's a PPI-powered grep. It's alpha and has many things it cannot yet search for. Currently we can only search through quoted text, heredocs, comments and POD. More features will be added in the future.
pgrep - grep through Perl documents.
pgrep [options] [files or directory]
Options which take arguments
-p, --pattern A Perl regular expression to match against. Default to the empty string. -s, --search What parts of the Perl document to search in. Defaults to C<--search quote,heredoc>.
Boolean options
-w, --warnings Enable warnings -l Filenames only -h, --help Display this help -?, Display this help -H, --man Longer manpage for prove
SEARCHES
The following parts of Perl documents may be searched for:
quote
heredoc
pod
comment
The --search
argument can accept a comma separate list of items to search
for:
--search pod,heredoc,quote
We'll add more things you can search for later.
All items may be plural to make them easier to read:
pgrep --search comments,heredocs --pattern 'XXX'
pgrep -pattern '^\s*(?i:select|insert|update|delete).*=\s*'?[\$\@]'
Because we default to searching for 'quote' and 'heredoc' elements, the above searches them for things like:
DELETE FROM table WHERE name='$name'
Due to the nature of SQL injection attacks, the above is very limited. See http://www.perlmonks.org/ for more information.
pgrep --search comments --pattern '(?i:XXX|TODO)' lib/
pgrep --search comments,pod --pattern '(?i:XXX|TODO)' lib/
=head3
in POD.
pgrep --search pod --pattern '^=head3' -l
If --dir
or --files
are not supplied, assumes we're search from the
current directory on down.
ack
, included with App::Ack
.
This is alpha code. You've been warned.
grep
depends on the shell to expand globs into a list of filenames, and this breaks down when your start descending into directories.Re:What's wrong with grep
Ovid on 2007-08-19T20:57:20
There's nothing wrong with grep. However, it's a different tool that attempts to satisfy a different need. I often want to search parts of a Perl document without searching all of it. Being able to search just through DATA sections or perhaps dump all regular expressions can be hand. You may have different needs. As time goes on, I'll be adding new features and it will be even more useful.
Also, I was going to add file extension support, but I decided to put that off as "not needed" for the first iteration. You could just use find and pipe the results through.
Patches welcome
:) Re:What's wrong with grep
Alias on 2007-08-19T21:52:39
If you just need a smarter grep, without the ability to understand Perl, you might want something like ack.
Re:pgrep
Ovid on 2007-08-20T09:57:24
Ah, crud. I hadn't heard of the command, so I didn't think to search for it. Thanks for the heads up. Recommendations welcome!
Re:pgrep
Aristotle on 2007-08-20T13:22:58
plgrep?
Re:pgrep
Aristotle on 2007-08-20T13:27:18
Hmm, that’s taken too. But ppgrep isn’t. Google only finds someone who uses that as their nickname and a page showing a Perl script called ppgrep that isn’t mentioned anywhere else.