You could implement the Chain of Responsibility design pattern by promoting ARG0 from an input string to a data structure that includes the input and the steps to process it.
First define a subroutine to pass the job to the next step in the recipe:
sub what_next { my ($kernel, $job) = @_; my $next_step = shift @{ $job->{recipe} }; if (defined $next_step) { $kernel->yield( $next_step => $job ); } else { $kernel->yield( 'process_next_input' ); } }
process_next_input() builds the job and the initial recipe, and then uses what_next() to start the process:
sub process_next_input { ...; my $job = { input => $next_input, recipe => [ 'step_one', 'step_two' ], }; what_next($_[KERNEL], $job); }
All stages of the process end by calling what_next() to pass the work on. You could get fancy by pushing coderefs onto the recipe that conditionally return the next event in the chain.
Sorry for not responding in so long. I'm doing PerlMonks wrong, and I don't notice my message inbox until I actively return to the site. If there's some sort of RSS-like way to check for messages, that would help a lot.
In reply to Re^3: POE::Wheel::ReadWrite: "low priority" events
by rcaputo
in thread POE::Wheel::ReadWrite: "low priority" events
by vlad_s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |