I know, I know Moose,Cataylst and DBIx class are the cat`s pajamas right now. :-) I am learning each module In the next 6 months to year writing code using all three. But, right now I need to write apps that run batch processes for my job that will eventually grow to a decent size script over 1000 to 2000 lines of good readable code that does a multitude of event driven tasks.
So, being a intermediate Perl programmer I want the code to be clean,easy to read and extensiable in PERL! I am studying the POE perl module and it seems to fit the bill and I will be using it to write out my little script for the team with exception handling in the next month posting my code for view and to learn from others.
POE is a Perl framework for writing reactive programs. Cooperatively multi-tasked programs and networking programs are overlapping subsets
of reactive programs.
POE implements a single API and bridges from it to other event loops.
A program using POE can run under any event loop that POE supports,
with little or no modification.
http://poe.perl.org/
CPAN POE module explanation:
POE - portable multitasking and networking framework for any event loop
Example code from CPAN POE:
#!/usr/bin/perl -w
use strict;
use POE; # Auto-includes POE::Kernel and POE::Session.
sub handler_start {
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
print "Session ", $session->ID, " has started.\n";
$heap->{count} = 0;
$kernel->yield('increment');
}
sub handler_increment {
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
print "Session ", $session->ID, " counted to ", ++$heap->{count}, ".\n";
$kernel->yield('increment') if $heap->{count} < 10;
}
sub handler_stop {
print "Session ", $_[SESSION]->ID, " has stopped.\n";
}
for (1..10) {
POE::Session->create(
inline_states => {
_start => \&handler_start,
increment => \&handler_increment,
_stop => \&handler_stop,
}
);
}
POE::Kernel->run();
exit;
Good pdf that I used to get a decent understanding of POEs` best practices.
Matt Sergeant (baud) presented a tutorial that covered the basics of
POE and explained many of the practical things it's good for. His
[slides and examples] are
online.
http://axkit.org/docs/presentations/tpc2002/
Recent Comments