App::Pebble - Unix like streams, but with objects instead of lines of text
The Unix idea of a stream of lines, on steroids.
Note: This is alpha, pure R&D at this stage; just trying out a good way to do things.
# pgrep, pn: Filter out POD lines, add a \n cat lib/App/Pebble.pm | pebble 'pgrep { /^=/ } | pn' =head1 NAME =head1 SYNOPSIS =head1 DESCRIPTION ... # The same, limit output to 2 lines cat lib/App/Pebble.pm | p 'pgrep { /^=head/ } | plimit 2 | pn' =head1 NAME =head1 SYNOPSIS
# P->match: Parse matching lines into objects with named attributes. # The default output format is one-line JSON. cat lib/App/Pebble.pm | \ p 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "text"] )' {"level":"1","text":"NAME"} {"level":"1","text":"SYNOPSIS"} {"level":"1","text":"DESCRIPTION"} ... ###TODO: split ###TODO: parsers # R->table: Do the same, but provide a Renderer (table) as the final stage cat lib/App/Pebble.pm | \ p 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "text"] ) | R->table' .-------------------------------. | level | text | +-------+-----------------------+ | 1 | NAME | | 1 | SYNOPSIS | | 1 | DESCRIPTION | ... '-------+-----------------------' # --out=CSV: Do the same, but provide a CSV renderer on the command line, # not as the final stage. # You can install more renderers, and write your own. cat lib/App/Pebble.pm | \ p --out=CSV 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "text"] )' level,text 1,NAME 1,SYNOPSIS 1,DESCRIPTION
# pgrep: Filter out headings with too long text cat lib/App/Pebble.pm | \ p --out=table 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "text"] ) | pgrep { length( $_->text) < 5 }' .--------------. | level | text | +-------+------+ | 1 | NAME | | 1 | BUGS | '-------+------'
# p / pmap: Shorten the text value to at most 5 chars # "pmap" is so commonly used it's aliased to "p" for convenience. # Note that you still want the object itself to be passed along in the stream, # so you need to end the block with $_; cat lib/App/Pebble.pm | p --out=table 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "text"] ) | p { $_->text( substr($_->text, 0, 5 )); $_ }' .---------------. | level | text | +-------+-------+ | 1 | NAME | | 1 | SYNOP | | 1 | DESCR | ...
###TODO: local variables
# --cmd=df: Run "df -k" and parse the output p --cmd=df --out=table 'plimit 2' .--------------------------------------------------------------------------. | available | blocks | capacity | filesystem | mounted_on | used | +-----------+-----------+----------+--------------+------------+-----------+ | 21856800 | 976101344 | 98 | /dev/disk0s2 | / | 953732544 | | 0 | 216 | 100 | devfs | /dev | 216 | '-----------+-----------+----------+--------------+------------+-----------'
Optional cache object, used for e.g. web requests.
Johan Lindstrom, <johanl at cpan.org>
<johanl at cpan.org>
Please report any bugs or feature requests to bug-app-pebble at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Pebble. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-app-pebble at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::Pebble
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Pebble
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-Pebble
CPAN Ratings
http://cpanratings.perl.org/d/App-Pebble
Search CPAN
http://search.cpan.org/dist/App-Pebble/
Copyright 2010- Johan Lindstrom.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install App::Pebble, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Pebble
CPAN shell
perl -MCPAN -e shell install App::Pebble
For more information on module installation, please visit the detailed CPAN module installation guide.