Elliot Shank > PPIx-Grep-v0.0.6 > ppigrep

Download:
PPIx-Grep-v0.0.6.tar.gz

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

ppigrep - Search PPI documents (not Perl code).

VERSION ^

This document describes ppigrep version 0.0.6.

USAGE ^

    ppigrep [--format format] PPI-class file [...]

    ppigrep { -h | --help | -V | --version }

DESCRIPTION ^

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 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

    foo.pl:1:6:'a'
    foo.pl:1:12:'b'

by default, even though both expressions were found on the same line.

REQUIRED ARGUMENTS ^

· PPI-class

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.

· file [...]

A list of files to search.

OPTIONS ^

· --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.

Specifiable fields are:

%f – The name of the file.
%l – The starting line number of the element.
%c – The starting character within the first line of the element.
%C – The starting column within the first line of the element. This will differ from %c when there are tab characters.
%L – The class of the element, with the 'PPI::' prefix removed (you can always get that back by prefixing this field with the 5 characters).
%s – The source-code/content for the element.
%S – The source-code/content for the element, chomped.
%W – The source-code/content for the element, leading and trailing whitespace removed and all other whitespace converted to a single space character.

· --help or -h

Emit a short description of this command and its options and quit.

· --version or -V

Emit the version of this command and quit.

EXAMPLES ^

Show all eval statements.
    ppigrep --format '%s' --match '^\s*eval' statement Some/Module.pm
Find all calls to the date program via back-ticks, e.g. `date`.
    ppigrep --match '\bdate\b' backtick Some/Module.pm

DIAGNOSTICS ^

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.

Could not figure out what PPI class to use for "%s".

The PPI-class argument could not be resolved to a subclass of PPI::Element via PPIx::Shorthand.

Could not find any PPI::Element subclasses to use for "%s".

The pattern argument didn't resolve to any PPI::Element subclasses. Did you specify the empty string?

Invalid regex "%s": %s.

The regex specified via --match could not be compiled.

"%s" does not exist.

Cannot find the file.

"%s" is not readable.

Cannot read the file.

"%s" is a directory.

The "file" was actually a directory.

Could not parse "%s".

PPI could not interpret the file as a Perl document.

CONFIGURATION AND ENVIRONMENT ^

None, yet.

DEPENDENCIES ^

PPIx::Grep

INCOMPATIBILITIES ^

None known.

BUGS AND LIMITATIONS ^

· This thing is way too limited in functionality.

Please report any bugs or feature requests to bug-ppix-grep@rt.cpan.org, or through the web interface at http://rt.cpan.org.

SEE ALSO ^

App::Ack App::Grepl

AUTHOR ^

Elliot Shank <perl@galumph.com>

LICENSE AND COPYRIGHT ^

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.

DISCLAIMER OF WARRANTY ^

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.

syntax highlighting: