App::Pgrep 0.01 to the CPAN

Ovid on 2007-08-19T18:49:35

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.


NAME

pgrep - grep through Perl documents.


USAGE

 pgrep [options] [files or directory]


OPTIONS

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
  • Matches quoted strings (but not heredocs).

  • heredoc
  • Matches heredocs.

  • pod
  • Matches POD.

  • comment
  • Matches comments.

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'


EXAMPLES


NOTES

Default Directory

If --dir or --files are not supplied, assumes we're search from the current directory on down.


SEE ALSO

ack, included with App::Ack.


CAVEATS

This is alpha code. You've been warned.


What's wrong with grep

bart on 2007-08-19T20:48:18

.. and the reason I'm interested in alternatives, is the option to specify file extensions (or more general: file name patterns) for the files to search in, specifically for recursive mode.

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.

pgrep

miyagawa on 2007-08-20T09:50:08

Nice work, but the name 'pgrep' is not probably the best one since there's a conflict.

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.