Re: writing sequential code in POE

Josh803316 <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
Hopefully I'm reading your question correctly but if you need a way to
syncronously and sequnetially call things I believe you can use "call":

http://search.cpan.org/~rcaputo/POE-1.006/lib/POE/Kernel.pm#call_DESTINATION,_EVENT_NAME_[,_PARAMETER_LIST]

On Mon, Jun 1, 2009 at 8:15 AM, jorge sanchez <[email protected]> wrote:

> Hi,
>
> I am writing a process spawner (utilizing POE::Wheel::Run) everything
> is OK but I also need
> to write sequential code and I simply don't know how to do that. The
> only way is to utilize
> the CALLER_STATE and call back the event which called another event.
>
> sub test
> {
> my ( $kernel, $heap, $caller_state ) = @_[ KERNEL, HEAP, CALLER_STATE ];
> print "This is the test \n";
> if ((defined  $caller_state) and ($caller_state eq "test2")) {
>        print "the caller state is $caller_state \n";
>        goto TEST;
>                                }
> $_[KERNEL]->yield("test2");
> goto END;
>
> TEST:
>        print "after the test2 \n";
>
> END:
> }
> sub test2
> {
> my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
> #print  $_[HEAP]{'test'};
> print "This is the test2 \n";
>
> $_[KERNEL]->yield("test");
>
>
> }
>
>
> Is this the only way how to do that or is there any other way?
>
>
> Regards,
>
> Jorge
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.