SlideShare a Scribd company logo
1 of 54
Download to read offline
P ip es
          m an tic
    Se

London
       Perl Wor
                k   sh o p 5 D
                                 e c 2009



                osfam
                                 eron
Everyone likes pipes
Unix philosophy



“This is the Unix philosophy: Write programs that do
  one thing and do it well. Write programs to work
  together. Write programs to handle text streams,
         because that is a universal interface.”
                                         – Doug McIlroy
                                   http://www.faqs.org/docs/artu/ch01s06.html
Pipes
generate

Foo foo foo
Bar bar bar
Baz baz baz

             map



       foo
       bar
       baz
Pipes
generate

Foo foo foo
Bar bar bar
Baz baz baz

             grep




Bar bar bar
Pipes
generate

Foo foo foo
Bar bar bar
Baz baz baz

             sort



Bar bar bar
Baz baz baz
Foo foo foo
ls
SYNOPSIS
       ls [OPTION]... [FILE]...

OPTIONS

          --format=WORD
                 across   -x, commas -m, horizontal -x, long -l, ...

          -h, --human-readable
                 human readable sizes (e.g., 1K 234M 2G)

          --hide=PATTERN
                 do not list implied entries matching shell PATTERN

          -r, --reverse
                 reverse order while sorting

          --sort=WORD
                 none -U, extension -X, size -S, time -t, version -v
ls
SYNOPSIS
       ls [OPTION]... [FILE]...

OPTIONS

          --format=WORD
                 across    -x, commas -m, horizontal -x, long -l, ...

          -h, --human-readable
                 human readable sizes (e.g., 1K 234M 2G)
           grep
          --hide=PATTERN
                 do not list implied entries matching shell PATTERN

          -r, --reverse
                 reverse order while sorting

          --sort=WORD
                 none -U, extension -X, size -S, time -t, version -v
ls
SYNOPSIS
       ls [OPTION]... [FILE]...

OPTIONS

          --format=WORD
                 across   -x, commas -m, horizontal -x, long -l, ...

          -h, --human-readable
                 human readable sizes (e.g., 1K 234M 2G)

          --hide=PATTERN
                 do not list implied entries matching shell PATTERN

          -r, --reverse
                 reverse order while sorting
           sort
          --sort=WORD
                 none -U, extension -X, size -S, time -t, version -v
ls
SYNOPSIS
       ls [OPTION]... [FILE]...

OPTIONS
           map/format
          --format=WORD
                 across   -x, commas -m, horizontal -x, long -l, ...

          -h, --human-readable
                 human readable sizes (e.g., 1K 234M 2G)

          --hide=PATTERN
                 do not list implied entries matching shell PATTERN

          -r, --reverse
                 reverse order while sorting

          --sort=WORD
                 none -U, extension -X, size -S, time -t, version -v
ls | … ?



ls | grep

ls | wc -l
ls -ltr | … ?



total 3272
-rwxr-xr-x   1   hakim   hakim      52   2009-12-02   20:52   pipe
-rw-r--r--   1   hakim   hakim     798   2009-12-03   00:49   pipe.pl
-rw-r--r--   1   hakim   hakim     905   2009-12-03   01:13   README
drwxr-xr-x   3   hakim   hakim    4096   2009-12-03   01:39   lib
-rw-r--r--   1   hakim   hakim     238   2009-12-04   23:05   images_list
-rw-r--r--   1   hakim   hakim 3323129   2009-12-04   23:17   semantic.odp
ls -ltr | … ?


    using cut
total 3272
-rwxr-xr-x   1   hakim   hakim      52   2009-12-02   20:52   pipe
-rw-r--r--   1   hakim   hakim     798   2009-12-03   00:49   pipe.pl
-rw-r--r--   1   hakim   hakim     905   2009-12-03   01:13   README
drwxr-xr-x   3   hakim   hakim    4096   2009-12-03   01:39   lib
-rw-r--r--   1   hakim   hakim     238   2009-12-04   23:05   images_list
-rw-r--r--   1   hakim   hakim 3323129   2009-12-04   23:17   semantic.odp
ls -ltr | … ?


   cut … --bytes? or --delimiter?
total 3272
-rwxr-xr-x   1   hakim   hakim      52   2009-12-02   20:52   pipe
-rw-r--r--   1   hakim   hakim     798   2009-12-03   00:49   pipe.pl
-rw-r--r--   1   hakim   hakim     905   2009-12-03   01:13   README
drwxr-xr-x   3   hakim   hakim    4096   2009-12-03   01:39   lib
-rw-r--r--   1   hakim   hakim     238   2009-12-04   23:05   images_list
-rw-r--r--   1   hakim   hakim 3323129   2009-12-04   23:17   semantic.odp
ls -ltr | … ?



total 3272
-rwxr-xr-x   1   hakim   hakim˽˽˽˽˽˽˽˽˽˽˽52   2009-12-02   20:52   pipe
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽798    2009-12-03   00:49   pipe.pl
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽905    2009-12-03   01:13   README
drwxr-xr-x   3   hakim   hakim˽˽˽˽˽˽˽4096     2009-12-03   01:39   lib
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽238    2009-12-04   23:05   images_list
-rw-r--r--   1   hakim   hakim˽˽3323129       2009-12-04   23:17   semantic.odp
ls -ltr | … ?



total 3272
-rwxr-xr-x   1   hakim   hakim˽˽˽˽˽˽˽˽˽˽˽52   2009-12-02   20:52   pipe
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽798    2009-12-03   00:49   pipe.pl
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽905    2009-12-03   01:13   README
drwxr-xr-x   3   hakim   hakim˽˽˽˽˽˽˽4096     2009-12-03   01:39   lib
-rw-r--r--   1   hakim   hakim˽˽˽˽˽˽˽˽˽238    2009-12-04   23:05   images_list
-rw-r--r--   1   hakim   hakim˽˽3323129       2009-12-04   23:17   semantic.odp
OK, find...
●   rather baroque
●   separate command
●   “consistent interface” ?
So who does do piping properly?
So who does do piping properly?
Windows Powershell
●   originally called Monad Shell
    ●   (this is important)
●   streams of .Net objects
●   flexible and consistent filter/map/sort
Disclaimer
●   I've never used Powershell...
Disclaimer
●   I've never used Powershell...
●   but the idea is genuinely exciting
Pipe.pm


package Pipe;
use Moose;
extends 'MooseX::App::Cmd';

1;
pipe



#!/usr/bin/perl
use lib 'lib';
use Pipe;
Pipe->run;
Pipe.pm
Pipe::Command::find
use Moose;
extends 'Pipe::Command';
use MooseX::Types::Path::Class qw(File to_File);
use File::Next;

sub go {
    my ($self, $session, $args) = @_;

    my @files = @$args;
    push @files, '.' unless @files;

    my $it = File::Next::files( @files );

    $session->iterator(
        sub {
            if (my $file = $it->()) {
                return to_File($file);
            } else {
                return;
            }
        });
}
Pipe::Command::grep
has where => (
    isa => 'Str',
    is => 'rw',
    documentation => 'string to match',
    );
has where_sub => ( … );

sub filter {
    my ($self, $session, $iterator) = @_;

    my $where_sub = $self->where_sub;

    my @queue;
    return sub { # yucky code, go read HOP instead
        return pop @queue if @queue;
        {
        my @values = $iterator->() or return;
        @queue = grep {
            my $result = eval { $where_sub->($_) };
            $result;
            } @values or redo;
        }
        return pop @queue;
    };
}
Pipe in action

$ ./pipe find lib

    List of files found!

    lib/Pipe/Command.pm
    lib/Pipe/Command/find.pm
    lib/Pipe/Command/grep.pm
    lib/Pipe/Session.pm
    lib/Pipe.pm
Pipe in action


$ ./pipe find lib |
  ./pipe grep '$_->stat->size > 1000'

    List of files found!

    lib/Pipe/Command.pm
Pipe::Command::find


sub pretty_print {
    my ($self, $session) = @_;

    say "List of files found!nn";
    my $it = $session->iterator;
    while (my @files = $it->()) {
        say join "n", @files;
    }
}
Pipe to an external tool
$ ./pipe find lib | cat
    ---
    command_stack: !!perl/hash:Pipe::Command::find
      app: !!perl/hash:Pipe
        arg0: pipe
            .
            . <snip>
            .
    --- !!perl/hash:Path::Class::File
    dir: !!perl/hash:Path::Class::Dir
      dirs:
      - lib
      file_spec_class: ~
      volume: ''
    file: Pipe.pm
    file_spec_class: ~
Pipe to an external tool



$ ./pipe find lib –-pretty | cat

   lib/Pipe/Command.pm
   lib/Pipe/Command/find.pm
   lib/Pipe/Command/grep.pm
   lib/Pipe/Session.pm
   lib/Pipe.pm
generate
             Pipes
app: !!Pipe
stack: generate
                     Foo foo foo
 blah blah blah      Bar bar bar
                     Baz baz baz
generate
                  Pipes
  app: !!Pipe
  stack: generate
                            Foo foo foo
   blah blah blah           Bar bar bar
   I'm using YAML,          Baz baz baz
but could just as well be
       XML etc.
generate
             Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe          foo
stack: map
       generate      bar
blah blah blah       baz
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe
stack: map
       generate
blah blah blah

           sort

app: !!Pipe               bar
stack: sort
       map                baz
       generate           foo
blah blah blah
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe
stack: map
       generate
blah blah blah
                          ●nothing left to pipe to
                          (! -p)
           sort           ●or --pretty



app: !!Pipe                      bar
stack: sort
       map                       baz
       generate                  foo
blah blah blah
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe
stack: map
       generate
blah blah blah
                          ●nothing left to pipe to
                          (! -p)
           sort           ●or --pretty



app: !!Pipe                      bar
stack: sort
       map                       baz
       generate                  foo
blah blah blah
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah
                          pretty_print
           map

app: !!Pipe
stack: map
       generate
blah blah blah

           sort

app: !!Pipe
stack: sort
       map
       generate
blah blah blah
Database
●   from mydb.foo |
       grep '$_->name =~ /Bob/' |
       select foo bar baz
Database
●   from mydb.foo | # 1 billion rows?
       grep '$_->name =~ /Bob/' |
       select foo bar baz
“You see, wire
telegraph is a kind of
a very, very long cat.
You pull his tail in
New York and his
head is meowing in
Los Angeles. Do you
understand this?
And radio operates
exactly the same
way: you send
signals here, they
receive them there.
The only difference
is that there is no
cat.”
“You see, wire
telegraph is a kind of
a very, very long cat.
You pull his tail in
New York and his
head is meowing in
Los Angeles. Do you
understand this?
And radio operates
exactly the same
way: you send
signals here, they
receive them there.
The only difference
is that there is no
cat.”
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe
stack: map
       generate
blah blah blah

           sort

app: !!Pipe
stack: sort
       map
       generate
blah blah blah
generate
                  Pipes
app: !!Pipe
stack: generate
 blah blah blah


           map

app: !!Pipe
stack: map
       generate
blah blah blah

           sort

app: !!Pipe
stack: sort
       map
       generate
blah blah blah
generate
        Pipes Monads
app: !!Pipe
stack: generate



          map

app: !!Pipe
stack: map
       generate



          sort

app: !!Pipe       generate
stack: sort       >> map
       map        >> sort
       generate   >> pretty_print
                   (first [sort, map, generate])
Thank you
●
    Details/links
    ●
        Early version of this talk given at NorthWestEngland.pm, 1st July 2009
    ●
        email: osfameron@cpan.org
    ●
        http://github.com/osfameron/pipe/
    ●
        http://github.com/rhaen/Bicycle-Workshop (nice MooseX::App::Cmd example)
●
    Images
    ●
        CC-licensed, via Flickr (thanks for making your photos free to use!!)
         –   http://www.flickr.com/photos/rxmflickr/4102530508/         Pipe Dream (title picture), by Rishi Menon
         –   http://www.flickr.com/photos/technodad/3827297755/         The Unix® License Plate takes a beach break, by technodad
         –   http://www.flickr.com/photos/darwinbell/2422933100/        Pipe Dreams, by Darwin Bell
         –   http://www.flickr.com/photos/heritagefutures/2106174676/   Urban Moose, by ausphoto!
         – http://www.flickr.com/photos/james_michael_hill/88311128/    Pipes, by james_michael_hill
         – http://www.flickr.com/photos/intherough/3244476512/          The Chain, by ...-Wink-...
         – http://www.flickr.com/photos/carlos/3224149/                 Pipe, by Nuevo Anden
    ●
        Classic images, via Google
         –   Einstein with pipe
         –   I'm a PC, from the Mac ads
         –   Ceci n'est pas une pipe
         –   Einstein

More Related Content

What's hot

Licão 06 process text streams with filters
Licão 06 process text streams with filtersLicão 06 process text streams with filters
Licão 06 process text streams with filtersAcácio Oliveira
 
Linea de comandos bioface zem800
Linea de comandos bioface zem800Linea de comandos bioface zem800
Linea de comandos bioface zem800thomaswarnerherrera
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scriptingdcarneir
 
Basic command of hadoop
Basic command of hadoopBasic command of hadoop
Basic command of hadoopAhmad Kabeer
 
Lecture1 2 intro-unix
Lecture1 2 intro-unixLecture1 2 intro-unix
Lecture1 2 intro-unixnghoanganh
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands Raghav Arora
 
apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010Thejas Nair
 
Commands documentaion
Commands documentaionCommands documentaion
Commands documentaionTejalNijai
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commandsAcácio Oliveira
 
Treebeard's Unix Cheat Sheet
Treebeard's Unix Cheat SheetTreebeard's Unix Cheat Sheet
Treebeard's Unix Cheat Sheetwensheng wei
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係Kiwamu Okabe
 
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian Harl
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian HarlOSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian Harl
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian HarlNETWAYS
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologistAjay Murali
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Top 10 Hadoop Shell Commands
Top 10 Hadoop Shell Commands Top 10 Hadoop Shell Commands
Top 10 Hadoop Shell Commands SimoniShah6
 

What's hot (20)

Licão 06 process text streams with filters
Licão 06 process text streams with filtersLicão 06 process text streams with filters
Licão 06 process text streams with filters
 
Linea de comandos bioface zem800
Linea de comandos bioface zem800Linea de comandos bioface zem800
Linea de comandos bioface zem800
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Basic command of hadoop
Basic command of hadoopBasic command of hadoop
Basic command of hadoop
 
Lecture1 2 intro-unix
Lecture1 2 intro-unixLecture1 2 intro-unix
Lecture1 2 intro-unix
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010apache pig performance optimizations talk at apachecon 2010
apache pig performance optimizations talk at apachecon 2010
 
Hadoop File System Shell Commands,
Hadoop File System Shell Commands,Hadoop File System Shell Commands,
Hadoop File System Shell Commands,
 
Commands documentaion
Commands documentaionCommands documentaion
Commands documentaion
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 
Treebeard's Unix Cheat Sheet
Treebeard's Unix Cheat SheetTreebeard's Unix Cheat Sheet
Treebeard's Unix Cheat Sheet
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係
 
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian Harl
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian HarlOSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian Harl
OSMC 2010 | RRDCacheD - how to escape the I/O hell by Sebastian Harl
 
archive A-Z linux
archive A-Z linuxarchive A-Z linux
archive A-Z linux
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologist
 
HDFS_Command_Reference
HDFS_Command_ReferenceHDFS_Command_Reference
HDFS_Command_Reference
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Top 10 Hadoop Shell Commands
Top 10 Hadoop Shell Commands Top 10 Hadoop Shell Commands
Top 10 Hadoop Shell Commands
 

Viewers also liked

CPAN Module Maintenance
CPAN Module MaintenanceCPAN Module Maintenance
CPAN Module MaintenanceDave Cross
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern PerlDave Cross
 
Perl from the ground up: variables and data types
Perl from the ground up: variables and data typesPerl from the ground up: variables and data types
Perl from the ground up: variables and data typesShmuel Fomberg
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate PerlDave Cross
 
The Professional Programmer
The Professional ProgrammerThe Professional Programmer
The Professional ProgrammerDave Cross
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
Perl from the ground up: objects and testing
Perl from the ground up: objects and testingPerl from the ground up: objects and testing
Perl from the ground up: objects and testingShmuel Fomberg
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
揭开Javascript的面纱
揭开Javascript的面纱揭开Javascript的面纱
揭开Javascript的面纱qiang
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Any event intro
Any event introAny event intro
Any event introqiang
 

Viewers also liked (12)

CPAN Module Maintenance
CPAN Module MaintenanceCPAN Module Maintenance
CPAN Module Maintenance
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
Perl from the ground up: variables and data types
Perl from the ground up: variables and data typesPerl from the ground up: variables and data types
Perl from the ground up: variables and data types
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate Perl
 
The Professional Programmer
The Professional ProgrammerThe Professional Programmer
The Professional Programmer
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Perl from the ground up: objects and testing
Perl from the ground up: objects and testingPerl from the ground up: objects and testing
Perl from the ground up: objects and testing
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
揭开Javascript的面纱
揭开Javascript的面纱揭开Javascript的面纱
揭开Javascript的面纱
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Any event intro
Any event introAny event intro
Any event intro
 

Similar to Semantic Pipes (London Perl Workshop 2009)

Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command LineLiz Henry
 
FunctionalJS - May 2014 - Streams
FunctionalJS - May 2014 - StreamsFunctionalJS - May 2014 - Streams
FunctionalJS - May 2014 - Streamsdarach
 
Fast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambdaFast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambdaMila Frerichs
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file managementAcácio Oliveira
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppthazhamina
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line toolsEric Wilson
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpointbijanshr
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1Leandro Lima
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to LinuxDimas Prasetyo
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Ranjan Raja
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
Rtfm_ Red Team Field Manual ( PDFDrive ).pdf
Rtfm_ Red Team Field Manual ( PDFDrive ).pdfRtfm_ Red Team Field Manual ( PDFDrive ).pdf
Rtfm_ Red Team Field Manual ( PDFDrive ).pdfMacMelter
 

Similar to Semantic Pipes (London Perl Workshop 2009) (20)

Unix Basics Commands
Unix Basics CommandsUnix Basics Commands
Unix Basics Commands
 
Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command Line
 
FunctionalJS - May 2014 - Streams
FunctionalJS - May 2014 - StreamsFunctionalJS - May 2014 - Streams
FunctionalJS - May 2014 - Streams
 
Fast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambdaFast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambda
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line tools
 
lec2.docx
lec2.docxlec2.docx
lec2.docx
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
Rtfm_ Red Team Field Manual ( PDFDrive ).pdf
Rtfm_ Red Team Field Manual ( PDFDrive ).pdfRtfm_ Red Team Field Manual ( PDFDrive ).pdf
Rtfm_ Red Team Field Manual ( PDFDrive ).pdf
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 

More from osfameron

Writing a Tile-Matching Game - FP Style
Writing a Tile-Matching Game - FP StyleWriting a Tile-Matching Game - FP Style
Writing a Tile-Matching Game - FP Styleosfameron
 
Data Structures for Text Editors
Data Structures for Text EditorsData Structures for Text Editors
Data Structures for Text Editorsosfameron
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
Rewriting the Apocalypse
Rewriting the ApocalypseRewriting the Apocalypse
Rewriting the Apocalypseosfameron
 
Global Civic Hacking 101 (lightning talk)
Global Civic Hacking 101 (lightning talk)Global Civic Hacking 101 (lightning talk)
Global Civic Hacking 101 (lightning talk)osfameron
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperosfameron
 
Adventures in civic hacking
Adventures in civic hackingAdventures in civic hacking
Adventures in civic hackingosfameron
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real Worldosfameron
 
Oyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloudOyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloudosfameron
 
Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)osfameron
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
Functional Pe(a)rls
Functional Pe(a)rlsFunctional Pe(a)rls
Functional Pe(a)rlsosfameron
 
Readable Perl
Readable PerlReadable Perl
Readable Perlosfameron
 

More from osfameron (15)

Writing a Tile-Matching Game - FP Style
Writing a Tile-Matching Game - FP StyleWriting a Tile-Matching Game - FP Style
Writing a Tile-Matching Game - FP Style
 
Data Structures for Text Editors
Data Structures for Text EditorsData Structures for Text Editors
Data Structures for Text Editors
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Rewriting the Apocalypse
Rewriting the ApocalypseRewriting the Apocalypse
Rewriting the Apocalypse
 
Global Civic Hacking 101 (lightning talk)
Global Civic Hacking 101 (lightning talk)Global Civic Hacking 101 (lightning talk)
Global Civic Hacking 101 (lightning talk)
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
Adventures in civic hacking
Adventures in civic hackingAdventures in civic hacking
Adventures in civic hacking
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real World
 
Oyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloudOyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloud
 
Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Functional Pe(a)rls
Functional Pe(a)rlsFunctional Pe(a)rls
Functional Pe(a)rls
 
Readable Perl
Readable PerlReadable Perl
Readable Perl
 
Bigbadwolf
BigbadwolfBigbadwolf
Bigbadwolf
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Semantic Pipes (London Perl Workshop 2009)

  • 1. P ip es m an tic Se London Perl Wor k sh o p 5 D e c 2009 osfam eron
  • 3.
  • 4. Unix philosophy “This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.” – Doug McIlroy http://www.faqs.org/docs/artu/ch01s06.html
  • 5. Pipes generate Foo foo foo Bar bar bar Baz baz baz map foo bar baz
  • 6. Pipes generate Foo foo foo Bar bar bar Baz baz baz grep Bar bar bar
  • 7. Pipes generate Foo foo foo Bar bar bar Baz baz baz sort Bar bar bar Baz baz baz Foo foo foo
  • 8.
  • 9. ls SYNOPSIS ls [OPTION]... [FILE]... OPTIONS --format=WORD across -x, commas -m, horizontal -x, long -l, ... -h, --human-readable human readable sizes (e.g., 1K 234M 2G) --hide=PATTERN do not list implied entries matching shell PATTERN -r, --reverse reverse order while sorting --sort=WORD none -U, extension -X, size -S, time -t, version -v
  • 10. ls SYNOPSIS ls [OPTION]... [FILE]... OPTIONS --format=WORD across -x, commas -m, horizontal -x, long -l, ... -h, --human-readable human readable sizes (e.g., 1K 234M 2G) grep --hide=PATTERN do not list implied entries matching shell PATTERN -r, --reverse reverse order while sorting --sort=WORD none -U, extension -X, size -S, time -t, version -v
  • 11. ls SYNOPSIS ls [OPTION]... [FILE]... OPTIONS --format=WORD across -x, commas -m, horizontal -x, long -l, ... -h, --human-readable human readable sizes (e.g., 1K 234M 2G) --hide=PATTERN do not list implied entries matching shell PATTERN -r, --reverse reverse order while sorting sort --sort=WORD none -U, extension -X, size -S, time -t, version -v
  • 12. ls SYNOPSIS ls [OPTION]... [FILE]... OPTIONS map/format --format=WORD across -x, commas -m, horizontal -x, long -l, ... -h, --human-readable human readable sizes (e.g., 1K 234M 2G) --hide=PATTERN do not list implied entries matching shell PATTERN -r, --reverse reverse order while sorting --sort=WORD none -U, extension -X, size -S, time -t, version -v
  • 13. ls | … ? ls | grep ls | wc -l
  • 14. ls -ltr | … ? total 3272 -rwxr-xr-x 1 hakim hakim 52 2009-12-02 20:52 pipe -rw-r--r-- 1 hakim hakim 798 2009-12-03 00:49 pipe.pl -rw-r--r-- 1 hakim hakim 905 2009-12-03 01:13 README drwxr-xr-x 3 hakim hakim 4096 2009-12-03 01:39 lib -rw-r--r-- 1 hakim hakim 238 2009-12-04 23:05 images_list -rw-r--r-- 1 hakim hakim 3323129 2009-12-04 23:17 semantic.odp
  • 15. ls -ltr | … ? using cut total 3272 -rwxr-xr-x 1 hakim hakim 52 2009-12-02 20:52 pipe -rw-r--r-- 1 hakim hakim 798 2009-12-03 00:49 pipe.pl -rw-r--r-- 1 hakim hakim 905 2009-12-03 01:13 README drwxr-xr-x 3 hakim hakim 4096 2009-12-03 01:39 lib -rw-r--r-- 1 hakim hakim 238 2009-12-04 23:05 images_list -rw-r--r-- 1 hakim hakim 3323129 2009-12-04 23:17 semantic.odp
  • 16. ls -ltr | … ? cut … --bytes? or --delimiter? total 3272 -rwxr-xr-x 1 hakim hakim 52 2009-12-02 20:52 pipe -rw-r--r-- 1 hakim hakim 798 2009-12-03 00:49 pipe.pl -rw-r--r-- 1 hakim hakim 905 2009-12-03 01:13 README drwxr-xr-x 3 hakim hakim 4096 2009-12-03 01:39 lib -rw-r--r-- 1 hakim hakim 238 2009-12-04 23:05 images_list -rw-r--r-- 1 hakim hakim 3323129 2009-12-04 23:17 semantic.odp
  • 17. ls -ltr | … ? total 3272 -rwxr-xr-x 1 hakim hakim˽˽˽˽˽˽˽˽˽˽˽52 2009-12-02 20:52 pipe -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽798 2009-12-03 00:49 pipe.pl -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽905 2009-12-03 01:13 README drwxr-xr-x 3 hakim hakim˽˽˽˽˽˽˽4096 2009-12-03 01:39 lib -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽238 2009-12-04 23:05 images_list -rw-r--r-- 1 hakim hakim˽˽3323129 2009-12-04 23:17 semantic.odp
  • 18. ls -ltr | … ? total 3272 -rwxr-xr-x 1 hakim hakim˽˽˽˽˽˽˽˽˽˽˽52 2009-12-02 20:52 pipe -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽798 2009-12-03 00:49 pipe.pl -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽905 2009-12-03 01:13 README drwxr-xr-x 3 hakim hakim˽˽˽˽˽˽˽4096 2009-12-03 01:39 lib -rw-r--r-- 1 hakim hakim˽˽˽˽˽˽˽˽˽238 2009-12-04 23:05 images_list -rw-r--r-- 1 hakim hakim˽˽3323129 2009-12-04 23:17 semantic.odp
  • 19. OK, find... ● rather baroque ● separate command ● “consistent interface” ?
  • 20. So who does do piping properly?
  • 21. So who does do piping properly?
  • 22. Windows Powershell ● originally called Monad Shell ● (this is important) ● streams of .Net objects ● flexible and consistent filter/map/sort
  • 23. Disclaimer ● I've never used Powershell...
  • 24. Disclaimer ● I've never used Powershell... ● but the idea is genuinely exciting
  • 25.
  • 29. Pipe::Command::find use Moose; extends 'Pipe::Command'; use MooseX::Types::Path::Class qw(File to_File); use File::Next; sub go { my ($self, $session, $args) = @_; my @files = @$args; push @files, '.' unless @files; my $it = File::Next::files( @files ); $session->iterator( sub { if (my $file = $it->()) { return to_File($file); } else { return; } }); }
  • 30. Pipe::Command::grep has where => ( isa => 'Str', is => 'rw', documentation => 'string to match', ); has where_sub => ( … ); sub filter { my ($self, $session, $iterator) = @_; my $where_sub = $self->where_sub; my @queue; return sub { # yucky code, go read HOP instead return pop @queue if @queue; { my @values = $iterator->() or return; @queue = grep { my $result = eval { $where_sub->($_) }; $result; } @values or redo; } return pop @queue; }; }
  • 31.
  • 32. Pipe in action $ ./pipe find lib List of files found! lib/Pipe/Command.pm lib/Pipe/Command/find.pm lib/Pipe/Command/grep.pm lib/Pipe/Session.pm lib/Pipe.pm
  • 33. Pipe in action $ ./pipe find lib | ./pipe grep '$_->stat->size > 1000' List of files found! lib/Pipe/Command.pm
  • 34. Pipe::Command::find sub pretty_print { my ($self, $session) = @_; say "List of files found!nn"; my $it = $session->iterator; while (my @files = $it->()) { say join "n", @files; } }
  • 35. Pipe to an external tool $ ./pipe find lib | cat --- command_stack: !!perl/hash:Pipe::Command::find app: !!perl/hash:Pipe arg0: pipe . . <snip> . --- !!perl/hash:Path::Class::File dir: !!perl/hash:Path::Class::Dir dirs: - lib file_spec_class: ~ volume: '' file: Pipe.pm file_spec_class: ~
  • 36. Pipe to an external tool $ ./pipe find lib –-pretty | cat lib/Pipe/Command.pm lib/Pipe/Command/find.pm lib/Pipe/Command/grep.pm lib/Pipe/Session.pm lib/Pipe.pm
  • 37.
  • 38. generate Pipes app: !!Pipe stack: generate Foo foo foo blah blah blah Bar bar bar Baz baz baz
  • 39. generate Pipes app: !!Pipe stack: generate Foo foo foo blah blah blah Bar bar bar I'm using YAML, Baz baz baz but could just as well be XML etc.
  • 40. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe foo stack: map generate bar blah blah blah baz
  • 41. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe stack: map generate blah blah blah sort app: !!Pipe bar stack: sort map baz generate foo blah blah blah
  • 42. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe stack: map generate blah blah blah ●nothing left to pipe to (! -p) sort ●or --pretty app: !!Pipe bar stack: sort map baz generate foo blah blah blah
  • 43. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe stack: map generate blah blah blah ●nothing left to pipe to (! -p) sort ●or --pretty app: !!Pipe bar stack: sort map baz generate foo blah blah blah
  • 44. generate Pipes app: !!Pipe stack: generate blah blah blah pretty_print map app: !!Pipe stack: map generate blah blah blah sort app: !!Pipe stack: sort map generate blah blah blah
  • 45. Database ● from mydb.foo | grep '$_->name =~ /Bob/' | select foo bar baz
  • 46. Database ● from mydb.foo | # 1 billion rows? grep '$_->name =~ /Bob/' | select foo bar baz
  • 47. “You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat.”
  • 48. “You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat.”
  • 49. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe stack: map generate blah blah blah sort app: !!Pipe stack: sort map generate blah blah blah
  • 50. generate Pipes app: !!Pipe stack: generate blah blah blah map app: !!Pipe stack: map generate blah blah blah sort app: !!Pipe stack: sort map generate blah blah blah
  • 51. generate Pipes Monads app: !!Pipe stack: generate map app: !!Pipe stack: map generate sort app: !!Pipe generate stack: sort >> map map >> sort generate >> pretty_print (first [sort, map, generate])
  • 52.
  • 53.
  • 54. Thank you ● Details/links ● Early version of this talk given at NorthWestEngland.pm, 1st July 2009 ● email: osfameron@cpan.org ● http://github.com/osfameron/pipe/ ● http://github.com/rhaen/Bicycle-Workshop (nice MooseX::App::Cmd example) ● Images ● CC-licensed, via Flickr (thanks for making your photos free to use!!) – http://www.flickr.com/photos/rxmflickr/4102530508/ Pipe Dream (title picture), by Rishi Menon – http://www.flickr.com/photos/technodad/3827297755/ The Unix® License Plate takes a beach break, by technodad – http://www.flickr.com/photos/darwinbell/2422933100/ Pipe Dreams, by Darwin Bell – http://www.flickr.com/photos/heritagefutures/2106174676/ Urban Moose, by ausphoto! – http://www.flickr.com/photos/james_michael_hill/88311128/ Pipes, by james_michael_hill – http://www.flickr.com/photos/intherough/3244476512/ The Chain, by ...-Wink-... – http://www.flickr.com/photos/carlos/3224149/ Pipe, by Nuevo Anden ● Classic images, via Google – Einstein with pipe – I'm a PC, from the Mac ads – Ceci n'est pas une pipe – Einstein