App-pltest

 view release on metacpan or  search on metacpan

pod/examples.pod  view on Meta::CPAN

L<David Oswald|https://youtu.be/euj54cqpGOE>).
This is no attempt to appropriate ownership, just to show how things are even
easier and more concise with pltest.

=head2 Dealing with Files

=over

=item Heads ...

I<People say the back of my head looks really nice -- but I don't see it. :-)>

If you want just I<n>, e.g. 10, lines from the head of each file, use the
optional number argument to B<-p>, along with B<-r> to reset the count.  The
program can be empty, but must be present, unless you're reading from stdin:

    pltest -rp10 '' file*

If you want the head up to a regexp, use the flip-flop operator, starting with
line number 1.  Use the print-if-true B<-P> loop option, again with B<-r> to
reset the count:

pod/examples.pod  view on Meta::CPAN

Again without the date and owner/group, which can also vary:

    pltest -o 'piped {
           keydiff $2
                if s!^[^d]\S+ \K.+? +(\d+) .{16} [^/]+/(.+)!Form "%10d", $1!e;
        } "tar", "-tvf", $_' *.tar *.tgz *.txz

=item Diff ELF Executables by Loaded Dependencies

You get the idea: you can do this for any command that outputs records with a
unique key.  This one looks at the required libraries and which file they came
from.  For a change, loop with B<-O> and C<$A(RGV)> to avoid the previous
examples' confusion between outer C<$_> which were the cli args, and the inner
one, which were the read lines:

    pltest -O 'piped {
           keydiff if s/^\t(.+\.so.*) => (.*) \(\w+\)/$2/;
        } ldd => $ARGV' exe1 exe2 lib*.so

It's even more useful if you use just the basename as a key, because version
numbers may change:



( run in 0.399 second using v1.01-cache-2.11-cpan-64827b87656 )