SlideShare una empresa de Scribd logo
1 de 79
Descargar para leer sin conexión
POE
Stefano Rodighiero
  OpenExp 2006
Perl
Object
Environment
       POE - A Perl Object Environment
?
    POE - A Perl Object Environment
Framework

     POE - A Perl Object Environment
Event
driven
    POE - A Perl Object Environment
Multitasking
Cooperativo
       POE - A Perl Object Environment
Single
thread
   POE - A Perl Object Environment
Networking

      POE - A Perl Object Environment
System
administration
        POE - A Perl Object Environment
GUI
  POE - A Perl Object Environment
POE - A Perl Object Environment
Component


  Wheel

            “Architettura”
 Session


 Kernel




                POE - A Perl Object Environment
Component


  Wheel
            Dispatch di eventi
 Session


 Kernel




               POE - A Perl Object Environment
Component


  Wheel
            Risponde agli eventi
 Session


 Kernel




                POE - A Perl Object Environment
Component

            “Plugin” per sessioni,
             incapsula insiemi di
  Wheel
               gestori di eventi
 Session    POE::Wheel::FollowTail
              POE::Wheel::Run
 Kernel




                 POE - A Perl Object Environment
Component


  Wheel            POE::Component::IRC
               POE::Component::Server::TCP
            POE::Component::Server::SimpleHTTP
                        …CPAN…
 Session


 Kernel




                      POE - A Perl Object Environment
POE - A Perl Object Environment
Un programma tipico

• Istanzia una o più sessioni
 • Esplicitamente, eventualmente usando
    delle Wheel
 • Implicitamente, con Componenti già
    pronti
• POE::Kernel->run()

                           POE - A Perl Object Environment
sub POE::Kernel::TRACE_EVENTS() { 1 }




                       POE - A Perl Object Environment
use POE;

     POE - A Perl Object Environment
for ( 1 .. 3 ) {
  POE::Session -> create(
    inline_states => {
      _start => sub { print quot;Start!nquot; },
      _stop => sub { print quot;Stop!nquot; }
    } );
}




                         POE - A Perl Object Environment
POE::Kernel->run();



            POE - A Perl Object Environment
_start

Session



             Kernel




          POE - A Perl Object Environment
_start

    Session

_start =>
  sub {
    print quot;Start!nquot;
                          Kernel
  }




                       POE - A Perl Object Environment
Passaggio di messaggi

            Accoda un evento, da inoltrare
  post()       alla session specificata

            Accoda un evento, da inoltrare
  yield()        alla session stessa

                Invoca - in maniera
            sincrona - un evento per una
  call()
                  sessione specificata


                         POE - A Perl Object Environment
Passaggio di messaggi

post()/yield()




                 POE - A Perl Object Environment
Passaggio di messaggi



call()




             POE - A Perl Object Environment
Comunicazione
 tra sessioni

        POE - A Perl Object Environment
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;;
       $poe_kernel->alias_set( quot;Santaquot; );
     },
     lettera => sub {
       print quot;Lettera da quot;
           . $poe_kernel->alias_list( $_[SENDER] );
     }
   }
);


                               POE - A Perl Object Environment
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;;
       $poe_kernel->alias_set( quot;Santaquot; );
     },
     lettera => sub {
       print quot;Lettera da quot;
           . $poe_kernel->alias_list( $_[SENDER] );
     }
   }
);


                               POE - A Perl Object Environment
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;;
       $poe_kernel->alias_set( quot;Santaquot; );
     },
     lettera => sub {
       print quot;Lettera da quot;
           . $poe_kernel->alias_list( $_[SENDER] );
     }
   }
);


                               POE - A Perl Object Environment
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;;
       $poe_kernel->alias_set( quot;Santaquot; );
     },
     lettera => sub {
       print quot;Lettera da quot;
           . $poe_kernel->alias_list( $_[SENDER] );
     }
   }
);


                               POE - A Perl Object Environment
# Sessione bimbo
POE::Session->create(
   inline_states => {
     _start => sub {
       $poe_kernel->alias_set( quot;Paolinoquot; );
       $poe_kernel->post( quot;Santaquot; => 'lettera' );
     },
   }
);




                              POE - A Perl Object Environment
# Sessione bimbo
POE::Session->create(
   inline_states => {
     _start => sub {
       $poe_kernel->alias_set( quot;Paolinoquot; );
       $poe_kernel->post( quot;Santaquot; => 'lettera' );
     },
   }
);




                              POE - A Perl Object Environment
Babbo Natale       _start




                                Kernel
Paolino
                         _start




                          POE - A Perl Object Environment
Babbo Natale




                               Kernel
Paolino



      post( quot;Santaquot;, quot;letteraquot; )


                         POE - A Perl Object Environment
lettera
          Babbo Natale




                               Kernel
Paolino




                         POE - A Perl Object Environment
lettera
           Babbo Natale
lettera




                                 Kernel
 Paolino



          post( quot;Santaquot;, quot;letteraquot; )


                           POE - A Perl Object Environment
POE - A Perl Object Environment
Wheel
   POE - A Perl Object Environment
Insiemi di
gestori di
  eventi
       POE - A Perl Object Environment
POE::
 Wheel::
FollowTail
      POE - A Perl Object Environment
use POE qw(
	

Wheel::FollowTail
);


              POE - A Perl Object Environment
$|++

   POE - A Perl Object Environment
POE::Session-create(
  inline_states = {...



              POE - A Perl Object Environment
_start = sub {
  my $heap = $_[ HEAP ];
  my $watcher = POE::Wheel::FollowTail-new(
     Filename     = 'logfile.log',
     PollInterval = 1,
     InputEvent   = 'input_state'
  );
  $heap-{ watcher } = $watcher;
} , ...



                           POE - A Perl Object Environment
_start = sub {
  my $heap = $_[ HEAP ];
  my $watcher = POE::Wheel::FollowTail-new(
     Filename     = 'logfile.log',
     PollInterval = 1,
     InputEvent   = 'input_state'
  );
  $heap-{ watcher } = $watcher;
} , ...



                           POE - A Perl Object Environment
_start = sub {
  my $heap = $_[ HEAP ];
  my $watcher = POE::Wheel::FollowTail-new(
     Filename     = 'logfile.log',
     PollInterval = 1,
     InputEvent   = 'input_state'
  );
  $heap-{ watcher } = $watcher;
} , ...



                           POE - A Perl Object Environment
_start = sub {
  my $heap = $_[ HEAP ];
  my $watcher = POE::Wheel::FollowTail-new(
     Filename     = 'logfile.log',
     PollInterval = 1,
     InputEvent   = 'input_state'
  );
  $heap-{ watcher } = $watcher;
} , ...



                           POE - A Perl Object Environment
_start = sub {
  my $heap = $_[ HEAP ];
  my $watcher = POE::Wheel::FollowTail-new(
     Filename     = 'logfile.log',
     PollInterval = 1,
     InputEvent   = 'input_state'
  );
  $heap-{ watcher } = $watcher;
} , ...



                           POE - A Perl Object Environment
input_state = sub {
  my $input = $_[ ARG0 ];
  print $input;
}



                POE - A Perl Object Environment
Session
__________
__________
__________
__________
__________
__________
             Wheel




                POE - A Perl Object Environment
Session
__________
__________
__________
                             input_event
__________
__________
__________
             Wheel




                POE - A Perl Object Environment
POE - A Perl Object Environment
POE
+ Test
+ IRC
    POE - A Perl Object Environment
Testing?
     POE - A Perl Object Environment
Failed 3/10
           tests


                 ?
Test                             IRC




                     POE - A Perl Object Environment
09:41  Quinn larsen: Avast!
               Whoreson swab!
               You failed 3/10 tests!




                       POE - A Perl Object Environment
?
Test                   IRC




           POE - A Perl Object Environment
Session

               POE::
              Wheel::
__________   FollowTail
__________
__________
__________
__________
__________




               POE::
             Component::
                IRC




                           POE - A Perl Object Environment
POE::
Component::
    IRC
       POE - A Perl Object Environment
use POE qw/ Wheel::FollowTail
             Component::IRC
          /;




                  POE - A Perl Object Environment
use Acme::Scurvy::Whoreson::BilgeRat;




                       POE - A Perl Object Environment
my $conf = {
    nick     = 'Quinn',
    ircname = 'HAR!',
    server = 'irc.freenode.net',
    port     = 6667
};
my $channel = '#scummbar';



                     POE - A Perl Object Environment
my $irc = POE::Component::IRC-spawn( %$conf )
  or die quot;HAR!!! $!quot;;




                              POE - A Perl Object Environment
POE::Session-create(
    package_states = [
        'main' = [ qw(
            _default
            _start
            irc_001
            irc_public
            tell_results
        ) ],
    ],
    heap = { irc = $irc }
);
                  POE - A Perl Object Environment
POE::Session-create(
    package_states = [
        'main' = [ qw(
            _default
            _start
            irc_001
            irc_public
            tell_results
        ) ],
    ],
    heap = { irc = $irc }
);
                  POE - A Perl Object Environment
POE::Session-create(
    package_states = [
        'main' = [ qw(
            _default
            _start
            irc_001
            irc_public
            tell_results
        ) ],
    ],
    heap = { irc = $irc }
);
                  POE - A Perl Object Environment
sub _start {
  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];

    my $watcher = POE::Wheel::FollowTail-new(
      Filename     = 'tests.log' ,
      PollInterval = 1 ,
      InputEvent   = 'tell_results'
    );

    $heap-{ watcher } = $watcher;

    my $irc_sess = $heap-{irc}-session_id();
    $kernel-post( $irc_sess = register = 'all' );
    $kernel-post( $irc_sess = connect = {} );
    undef;
}

                                     POE - A Perl Object Environment
sub _start {
  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];

    my $watcher = POE::Wheel::FollowTail-new(
      Filename     = 'tests.log' ,
      PollInterval = 1 ,
      InputEvent   = 'tell_results'
    );

    $heap-{ watcher } = $watcher;

    my $irc_sess = $heap-{irc}-session_id();
    $kernel-post( $irc_sess = register = 'all' );
    $kernel-post( $irc_sess = connect = {} );
    undef;
}

                                     POE - A Perl Object Environment
sub _start {
  my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];

    my $watcher = POE::Wheel::FollowTail-new(
      Filename     = 'tests.log' ,
      PollInterval = 1 ,
      InputEvent   = 'tell_results'
    );

    $heap-{ watcher } = $watcher;

    my $irc_sess = $heap-{irc}-session_id();
    $kernel-post( $irc_sess = register = 'all' );
    $kernel-post( $irc_sess = connect = {} );
    undef;
}

                                     POE - A Perl Object Environment
sub irc_001 {
    my ( $kernel, $sender ) =
      @_[ KERNEL, SENDER ];

    $kernel-post(
      $sender = join = $channel );
    undef;
}



                       POE - A Perl Object Environment
sub tell_results
{
  my $kernel         =   $_[KERNEL];
  my $heap           =   $_[HEAP];
  my $line           =   $_[ARG0];
  my $irc_session    =   $heap-{irc};

    my ($failed, $total) = split qr|/|, $line;

    if ($failed) {
      my $insult = Acme::Scurvy::Whoreson::BilgeRat-new(
         language = 'pirate'
      );

        $kernel-post(
          $irc_session = privmsg =
            $channel = quot;$insult! You failed $failed tests!quot; );
        }
    }
}

                                          POE - A Perl Object Environment
sub tell_results
{
  my $kernel         =   $_[KERNEL];
  my $heap           =   $_[HEAP];
  my $line           =   $_[ARG0];
  my $irc_session    =   $heap-{irc};

    my ($failed, $total) = split qr|/|, $line;

    if ($failed) {
      my $insult = Acme::Scurvy::Whoreson::BilgeRat-new(
         language = 'pirate'
      );

        $kernel-post(
          $irc_session = privmsg =
            $channel = quot;$insult! You failed $failed tests!quot; );
        }
    }
}

                                          POE - A Perl Object Environment
sub tell_results
{
  my $kernel         =   $_[KERNEL];
  my $heap           =   $_[HEAP];
  my $line           =   $_[ARG0];
  my $irc_session    =   $heap-{irc};

    my ($failed, $total) = split qr|/|, $line;

    if ($failed) {
      my $insult = Acme::Scurvy::Whoreson::BilgeRat-new(
         language = 'pirate'
      );

        $kernel-post(
          $irc_session = privmsg =
            $channel = quot;$insult! You failed $failed tests!quot; );
        }
    }
}

                                          POE - A Perl Object Environment
POE - A Perl Object Environment
• irc.freenode.net,#poe
• http://poe.perl.org
• “Advanced Perl
  Programming” (O’Reilly) - Cap.7
• http://del.icio.us/slr/poe               ☺


                        POE - A Perl Object Environment
• http://www.perl.it
• irc.freenode.net,#perl.it
• mongers@perl.it


                   POE - A Perl Object Environment
Grazie!
Stefano Rodighiero
  larsen@perl.it

Más contenido relacionado

La actualidad más candente

The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?Tushar Sharma
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEThiago Rondon
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Workhorse Computing
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Workhorse Computing
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationWorkhorse Computing
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsMark Baker
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Workhorse Computing
 
Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Fwdays
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CDavid Wheeler
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 

La actualidad más candente (20)

Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"
 
DevOps with Fabric
DevOps with FabricDevOps with Fabric
DevOps with Fabric
 
Short Introduction To "perl -d"
Short Introduction To "perl -d"Short Introduction To "perl -d"
Short Introduction To "perl -d"
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning C
 
Smoking docker
Smoking dockerSmoking docker
Smoking docker
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 

Similar a POE

The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)Fabien Potencier
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門lestrrat
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteLeonardo Proietti
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012Tim Bunce
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0Tim Bunce
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Carlos Sanchez
 
Perforce Object and Record Model
Perforce Object and Record Model  Perforce Object and Record Model
Perforce Object and Record Model Perforce
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStackBram Vogelaar
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10acme
 
Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Robert Treat
 

Similar a POE (20)

The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Tutorial Puppet
Tutorial PuppetTutorial Puppet
Tutorial Puppet
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
 
effective_r27
effective_r27effective_r27
effective_r27
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Os Treat
Os TreatOs Treat
Os Treat
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
 
Perforce Object and Record Model
Perforce Object and Record Model  Perforce Object and Record Model
Perforce Object and Record Model
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStack
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007
 
Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010
 

Más de Stefano Rodighiero

Más de Stefano Rodighiero (8)

Perl101 - Italian Perl Workshop 2011
Perl101 - Italian Perl Workshop 2011Perl101 - Italian Perl Workshop 2011
Perl101 - Italian Perl Workshop 2011
 
On the most excellent theory of time travel, poetic revolutions, and dynamic ...
On the most excellent theory of time travel, poetic revolutions, and dynamic ...On the most excellent theory of time travel, poetic revolutions, and dynamic ...
On the most excellent theory of time travel, poetic revolutions, and dynamic ...
 
Perl101
Perl101Perl101
Perl101
 
Perl Template Toolkit
Perl Template ToolkitPerl Template Toolkit
Perl Template Toolkit
 
Test Automatici^2 per applicazioni Web
Test Automatici^2 per applicazioni WebTest Automatici^2 per applicazioni Web
Test Automatici^2 per applicazioni Web
 
Hacking Movable Type
Hacking Movable TypeHacking Movable Type
Hacking Movable Type
 
Perl, musica automagica
Perl, musica automagicaPerl, musica automagica
Perl, musica automagica
 
Scatole Nere
Scatole NereScatole Nere
Scatole Nere
 

Último

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
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
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
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
 
"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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
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
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
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!
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
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
 
"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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

POE

  • 2. Perl Object Environment POE - A Perl Object Environment
  • 3. ? POE - A Perl Object Environment
  • 4. Framework POE - A Perl Object Environment
  • 5. Event driven POE - A Perl Object Environment
  • 6. Multitasking Cooperativo POE - A Perl Object Environment
  • 7. Single thread POE - A Perl Object Environment
  • 8. Networking POE - A Perl Object Environment
  • 9. System administration POE - A Perl Object Environment
  • 10. GUI POE - A Perl Object Environment
  • 11. POE - A Perl Object Environment
  • 12. Component Wheel “Architettura” Session Kernel POE - A Perl Object Environment
  • 13. Component Wheel Dispatch di eventi Session Kernel POE - A Perl Object Environment
  • 14. Component Wheel Risponde agli eventi Session Kernel POE - A Perl Object Environment
  • 15. Component “Plugin” per sessioni, incapsula insiemi di Wheel gestori di eventi Session POE::Wheel::FollowTail POE::Wheel::Run Kernel POE - A Perl Object Environment
  • 16. Component Wheel POE::Component::IRC POE::Component::Server::TCP POE::Component::Server::SimpleHTTP …CPAN… Session Kernel POE - A Perl Object Environment
  • 17. POE - A Perl Object Environment
  • 18. Un programma tipico • Istanzia una o più sessioni • Esplicitamente, eventualmente usando delle Wheel • Implicitamente, con Componenti già pronti • POE::Kernel->run() POE - A Perl Object Environment
  • 19. sub POE::Kernel::TRACE_EVENTS() { 1 } POE - A Perl Object Environment
  • 20. use POE; POE - A Perl Object Environment
  • 21. for ( 1 .. 3 ) { POE::Session -> create( inline_states => { _start => sub { print quot;Start!nquot; }, _stop => sub { print quot;Stop!nquot; } } ); } POE - A Perl Object Environment
  • 22. POE::Kernel->run(); POE - A Perl Object Environment
  • 23. _start Session Kernel POE - A Perl Object Environment
  • 24. _start Session _start => sub { print quot;Start!nquot; Kernel } POE - A Perl Object Environment
  • 25. Passaggio di messaggi Accoda un evento, da inoltrare post() alla session specificata Accoda un evento, da inoltrare yield() alla session stessa Invoca - in maniera sincrona - un evento per una call() sessione specificata POE - A Perl Object Environment
  • 26. Passaggio di messaggi post()/yield() POE - A Perl Object Environment
  • 27. Passaggio di messaggi call() POE - A Perl Object Environment
  • 28. Comunicazione tra sessioni POE - A Perl Object Environment
  • 29. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  • 30. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  • 31. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  • 32. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  • 33. # Sessione bimbo POE::Session->create( inline_states => { _start => sub { $poe_kernel->alias_set( quot;Paolinoquot; ); $poe_kernel->post( quot;Santaquot; => 'lettera' ); }, } ); POE - A Perl Object Environment
  • 34. # Sessione bimbo POE::Session->create( inline_states => { _start => sub { $poe_kernel->alias_set( quot;Paolinoquot; ); $poe_kernel->post( quot;Santaquot; => 'lettera' ); }, } ); POE - A Perl Object Environment
  • 35. Babbo Natale _start Kernel Paolino _start POE - A Perl Object Environment
  • 36. Babbo Natale Kernel Paolino post( quot;Santaquot;, quot;letteraquot; ) POE - A Perl Object Environment
  • 37. lettera Babbo Natale Kernel Paolino POE - A Perl Object Environment
  • 38. lettera Babbo Natale lettera Kernel Paolino post( quot;Santaquot;, quot;letteraquot; ) POE - A Perl Object Environment
  • 39. POE - A Perl Object Environment
  • 40. Wheel POE - A Perl Object Environment
  • 41. Insiemi di gestori di eventi POE - A Perl Object Environment
  • 42. POE:: Wheel:: FollowTail POE - A Perl Object Environment
  • 43. use POE qw( Wheel::FollowTail ); POE - A Perl Object Environment
  • 44. $|++ POE - A Perl Object Environment
  • 45. POE::Session-create( inline_states = {... POE - A Perl Object Environment
  • 46. _start = sub { my $heap = $_[ HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'logfile.log', PollInterval = 1, InputEvent = 'input_state' ); $heap-{ watcher } = $watcher; } , ... POE - A Perl Object Environment
  • 47. _start = sub { my $heap = $_[ HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'logfile.log', PollInterval = 1, InputEvent = 'input_state' ); $heap-{ watcher } = $watcher; } , ... POE - A Perl Object Environment
  • 48. _start = sub { my $heap = $_[ HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'logfile.log', PollInterval = 1, InputEvent = 'input_state' ); $heap-{ watcher } = $watcher; } , ... POE - A Perl Object Environment
  • 49. _start = sub { my $heap = $_[ HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'logfile.log', PollInterval = 1, InputEvent = 'input_state' ); $heap-{ watcher } = $watcher; } , ... POE - A Perl Object Environment
  • 50. _start = sub { my $heap = $_[ HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'logfile.log', PollInterval = 1, InputEvent = 'input_state' ); $heap-{ watcher } = $watcher; } , ... POE - A Perl Object Environment
  • 51. input_state = sub { my $input = $_[ ARG0 ]; print $input; } POE - A Perl Object Environment
  • 53. Session __________ __________ __________ input_event __________ __________ __________ Wheel POE - A Perl Object Environment
  • 54. POE - A Perl Object Environment
  • 55. POE + Test + IRC POE - A Perl Object Environment
  • 56. Testing? POE - A Perl Object Environment
  • 57. Failed 3/10 tests ? Test IRC POE - A Perl Object Environment
  • 58. 09:41 Quinn larsen: Avast! Whoreson swab! You failed 3/10 tests! POE - A Perl Object Environment
  • 59. ? Test IRC POE - A Perl Object Environment
  • 60. Session POE:: Wheel:: __________ FollowTail __________ __________ __________ __________ __________ POE:: Component:: IRC POE - A Perl Object Environment
  • 61. POE:: Component:: IRC POE - A Perl Object Environment
  • 62. use POE qw/ Wheel::FollowTail Component::IRC /; POE - A Perl Object Environment
  • 63. use Acme::Scurvy::Whoreson::BilgeRat; POE - A Perl Object Environment
  • 64. my $conf = { nick = 'Quinn', ircname = 'HAR!', server = 'irc.freenode.net', port = 6667 }; my $channel = '#scummbar'; POE - A Perl Object Environment
  • 65. my $irc = POE::Component::IRC-spawn( %$conf ) or die quot;HAR!!! $!quot;; POE - A Perl Object Environment
  • 66. POE::Session-create( package_states = [ 'main' = [ qw( _default _start irc_001 irc_public tell_results ) ], ], heap = { irc = $irc } ); POE - A Perl Object Environment
  • 67. POE::Session-create( package_states = [ 'main' = [ qw( _default _start irc_001 irc_public tell_results ) ], ], heap = { irc = $irc } ); POE - A Perl Object Environment
  • 68. POE::Session-create( package_states = [ 'main' = [ qw( _default _start irc_001 irc_public tell_results ) ], ], heap = { irc = $irc } ); POE - A Perl Object Environment
  • 69. sub _start { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'tests.log' , PollInterval = 1 , InputEvent = 'tell_results' ); $heap-{ watcher } = $watcher; my $irc_sess = $heap-{irc}-session_id(); $kernel-post( $irc_sess = register = 'all' ); $kernel-post( $irc_sess = connect = {} ); undef; } POE - A Perl Object Environment
  • 70. sub _start { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'tests.log' , PollInterval = 1 , InputEvent = 'tell_results' ); $heap-{ watcher } = $watcher; my $irc_sess = $heap-{irc}-session_id(); $kernel-post( $irc_sess = register = 'all' ); $kernel-post( $irc_sess = connect = {} ); undef; } POE - A Perl Object Environment
  • 71. sub _start { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; my $watcher = POE::Wheel::FollowTail-new( Filename = 'tests.log' , PollInterval = 1 , InputEvent = 'tell_results' ); $heap-{ watcher } = $watcher; my $irc_sess = $heap-{irc}-session_id(); $kernel-post( $irc_sess = register = 'all' ); $kernel-post( $irc_sess = connect = {} ); undef; } POE - A Perl Object Environment
  • 72. sub irc_001 { my ( $kernel, $sender ) = @_[ KERNEL, SENDER ]; $kernel-post( $sender = join = $channel ); undef; } POE - A Perl Object Environment
  • 73. sub tell_results { my $kernel = $_[KERNEL]; my $heap = $_[HEAP]; my $line = $_[ARG0]; my $irc_session = $heap-{irc}; my ($failed, $total) = split qr|/|, $line; if ($failed) { my $insult = Acme::Scurvy::Whoreson::BilgeRat-new( language = 'pirate' ); $kernel-post( $irc_session = privmsg = $channel = quot;$insult! You failed $failed tests!quot; ); } } } POE - A Perl Object Environment
  • 74. sub tell_results { my $kernel = $_[KERNEL]; my $heap = $_[HEAP]; my $line = $_[ARG0]; my $irc_session = $heap-{irc}; my ($failed, $total) = split qr|/|, $line; if ($failed) { my $insult = Acme::Scurvy::Whoreson::BilgeRat-new( language = 'pirate' ); $kernel-post( $irc_session = privmsg = $channel = quot;$insult! You failed $failed tests!quot; ); } } } POE - A Perl Object Environment
  • 75. sub tell_results { my $kernel = $_[KERNEL]; my $heap = $_[HEAP]; my $line = $_[ARG0]; my $irc_session = $heap-{irc}; my ($failed, $total) = split qr|/|, $line; if ($failed) { my $insult = Acme::Scurvy::Whoreson::BilgeRat-new( language = 'pirate' ); $kernel-post( $irc_session = privmsg = $channel = quot;$insult! You failed $failed tests!quot; ); } } } POE - A Perl Object Environment
  • 76. POE - A Perl Object Environment
  • 77. • irc.freenode.net,#poe • http://poe.perl.org • “Advanced Perl Programming” (O’Reilly) - Cap.7 • http://del.icio.us/slr/poe ☺ POE - A Perl Object Environment
  • 78. • http://www.perl.it • irc.freenode.net,#perl.it • mongers@perl.it POE - A Perl Object Environment
  • 79. Grazie! Stefano Rodighiero larsen@perl.it