logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: How to modify HEAP variables in subs...: msg#00053

Subject: Re: How to modify HEAP variables in subs...
"Laura" <laura@xxxxxxxx> writes:
>
> Why doesn`t variables of HEAP changed?
> There is a little chunk of program(2 subs):
>
> sub one {
>
> $_[HEAP]->{VARIABLE}=0;
> for(1..4)
> {
> $_[KERNEL]->yield("two");
> }
> print "VARIABLE: ",$_[HEAP]->{VARIABLE};
>
> }
>
> sub two {
> $_[HEAP]->{VARIABLE}++;
> }
>
> It will print "VARIABLE: 0", but why? I`ve updated it in 
> 'two', it must be 1(cause of ++).

In one() you schedule an event to run four times. When you return from
one() you give control back to POE. POE can then process the queue and
dispatch the four 'two'-events.

events are not object methods.. 






Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>