App-PTP

 view release on metacpan or  search on metacpan

script/ptp  view on Meta::CPAN

Filter all the lines using the given regex (inverted with B<-V> before the
B<-g> option), or replace all the match of the regex by the given substitution
string.

=item B<-p> I<perl code>

Execute the given code for each lines of input (the line is in B<$_> that can be
modified).

=item B<-n> I<perl code>

Replace each line by the return value of the given code (the input line is in
B<$_>).

=item B<--sort>, B<--uniq>, B<--head> I<n>, B<--tail> I<n>, B<--reverse>, B<--shuffle>, ...

Sort the file, remove duplicate lines, keep the first or last lines, reverse the
file, randomly shuffle the file, etc.

=item B<--pivot>, B<--anti-pivot>, B<--transpose>

Join all the lines into a single lines (B<--pivot>), or split the fields of each
lines into multiple lines (B<--anti-pivot>). Invert lines and column (fields on
a line) with B<--transpose>.

=item B<--cut> I<f1,f2,...>

Keep only the given fields of each line (by default fields can be separated by
tabs or comma, they will be separated by tabs in the output, this can be
overridden with B<-F> and B<-P>).

=item B<--paste> I<filename>

Join each line of the current file with the matching line of the given filename.

=item B<--tee> I<filename>, B<--shell> I<command>

Write the content of the file to the give filename or send it to the given shell
command.

=item B<-o> I<filename>, B<-a> I<filename>, B<-i>

Write the output to the given file (instead of the standard output), or append
to the file, or write it in-place in the input files.

=back

=head1 DESCRIPTION

B<PTP> is a versatile and expressive text processor program. The core features
that it tries to provide are the following:

=over 8

=item * Provide B<grep>, B<sed>-like and other operations with a coherent
regular expression language (B<grep> has a B<-P> flag but B<sed> has nothing of
the like).

=item * Provide a powerful input/output files support, that is lacking when
using vanilla-Perl one-liner (recursion in directories, output in-place with
optional backups, etc.).

=item * Pipelining of multiple operations on multiple files (using a pipeline
made of several standard tool usually makes it difficult to process several
input files at once).

=back

See examples of B<PTP> in action below, in the L</EXAMPLES> section.

=head1 OPTIONS

All options are case sensitive and can be abbreviated down to uniqueness.
However, it is recommended to use only the variants that are documented here, in
case options are introduced in the future that render some abbreviations
ambiguous. Unless specified otherwise, the arguments to all the options are
mandatory (for brevity they are usually documented only on the short form of the
options, but they are mandatory for the long form too).

The program expects four different kinds of arguments (all described below).
They can be mixed in any order that you want. However, for some of these
arguments the order is actually meaningful (e.g. the commands are applied in the
order in which they are specified):

=over 4

=item * L</INPUT FILES> can be specified anywhere on the command line, except
between another flag and its argument.

=item * L</PIPELINE COMMANDS>, which describe what operations should be executed
on each input files. The commands are all executed, in the order in which they
are specified on the command line, and applied to all input files.

=item * L</PROGRAM BEHAVIOR> options, set global options for the program. These
flags can appear multiple times on the command line, but only the last occurrence
will be used. To avoid mistakes, the program will stop with an error when some
of these flags are specified more than once.

=item * L</PIPELINE MODES> flags, which modify how the pipeline commands behave.
These flags have effect starting at the point where they are specified for all
the pipeline commands that are specified after them. Usually, each of these
flags will have an opposite flag that allows to revert to the default behavior
if needed.

=back

=head2 INPUT FILES

Input files can be specified anywhere on the command line. They will be
processed in the order in which they appear but their position relative to other
arguments is ignored. Any command line argument that does not start with a B<->
is considered to be a filename (unless it is an argument to a preceding flag).

A single B<-> alone indicates that the standard input will be processed, this
can be mixed with reading other files. If no input files at all are specified
then the standard input is processed.

Finally, you can stop the processing of the command line arguments by
specifying a B<--> option. In that case, all remaining arguments will be
considered as input files, even if they start with a B<->.



( run in 0.445 second using v1.01-cache-2.11-cpan-df04353d9ac )