var watchers restricted?

[email protected] (Jochen Stenzel)
Newsgroups perl.loop
Message-ID <[email protected]>
Hello,

are there limitations in the type of variables or accesses var watchers
can check?

I tried to watch the deletion of a hash element. This did not work
regardless if I watched the complete hash or the element itself.

If I watch a complete hash, element modifications are not recognized.

If I watch an array element, assignments are recognized, but if I assign
via push(), this is ignored.

If I watch an array completely, Event reports an exception if I access
the array by push(). This case is activated in the attached hack.

Greetings

                    Jochen
vardel.pl (application/x-perl, 723 B)
#!./perl -w

use strict;

use Event qw(time);

my (%oops, @oops);
$oops{'test'}=1;
Event->var(var=>\@oops, cb=>sub {warn "Here we go.\n";}, poll=>'rw');

# install a timer that modifies variables randomly
Event->timer(interval=>1, repeat=>1, cb=>sub {
                                              # $oops{'test'}++;
                                              # delete $oops{'test'};
                                              push(@oops, 1);
                                              #$oops[0]=3;
	                                      warn "---> MODIFIED.\n"; 
	                                      # $_[0]->w->cancel;
                                             }
            );

# start loop
Event::loop();
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.