ppigrep - Search PPI documents (not Perl code).
This document describes ppigrep version 0.0.6.
ppigrep [--format format] PPI-class file [...] ppigrep { -h | --help | -V | --version }
ppigrep is meant as a means of more intelligently searching PPI documents than via ack or grep. You might know PPI documents better as Perl code, but there are valid PPI documents that are not valid Perl. See the PPI documentation for the details on the differences.
ppigrep
grep
ppigrep does not search or emit lines from your files. It searches and emits the contents of PPI::Elements, which may consist of partial or multiple lines. Thus, given a file foo.pl which contains
$x = 'a' . 'b';
ppigrep quote foo.pl will emit
ppigrep quote foo.pl
foo.pl:1:6:'a' foo.pl:1:12:'b'
by default, even though both expressions were found on the same line.
A comma-delimited list of names of PPI::Element subclasses to search for, as recognizable by PPIx::Shorthand.
For example, you could specify "package,include" to get all instances of PPI::Statement::Package and PPI::Statement::Include.
A list of files to search.
--match
A Perl regular expression that each PPI::Element's contents must match.
--format format
A printf-like format for the output for each found PPI::Element. The default value is %f:%l:%c:%s.
printf
%f:%l:%c:%s
Specifiable fields are:
%f
%l
%c
%C
%L
%s
%S
chomp
%W
--help
-h
Emit a short description of this command and its options and quit.
--version
-V
Emit the version of this command and quit.
eval
ppigrep --format '%s' --match '^\s*eval' statement Some/Module.pm
`date`
ppigrep --match '\bdate\b' backtick Some/Module.pm
Exits with a value that is equivalent to the one for grep. If a match was found, this is 0. If no match was found, this is 1. And if any problems occurred, this is 2.
The PPI-class argument could not be resolved to a subclass of PPI::Element via PPIx::Shorthand.
PPI::Element
The pattern argument didn't resolve to any PPI::Element subclasses. Did you specify the empty string?
The regex specified via --match could not be compiled.
Cannot find the file.
Cannot read the file.
The "file" was actually a directory.
PPI could not interpret the file as a Perl document.
None, yet.
PPIx::Grep
None known.
Please report any bugs or feature requests to bug-ppix-grep@rt.cpan.org, or through the web interface at http://rt.cpan.org.
bug-ppix-grep@rt.cpan.org
App::Ack App::Grepl
Elliot Shank <perl@galumph.com>
<perl@galumph.com>
Copyright ©2007-2008, Elliot Shank <perl@galumph.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install PPIx::Grep, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PPIx::Grep
CPAN shell
perl -MCPAN -e shell install PPIx::Grep
For more information on module installation, please visit the detailed CPAN module installation guide.