here is the code. it is not too long. this doesn't core dump but it
looks for cancel.pm

perl foo.pl 
Stem::Event::Plain::Test testing
end test
Can't locate Event/cancel.pm in @INC (@INC contains: 
/usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 
.) at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/Event.pm line 50.
, Undefined subroutine &cancel at foo.pl line 0
END failed--cleanup aborted.


when i call the cancel i get this error:

Stem::Event::Plain::Test testing
success
Event: '?? foo.pl:33' died and then $Event::DIED died with: Can't locate Event/desc.pm 
in @INC (@INC contains: /usr/local/lib/perl5/5.00503/sun4-solaris 
/usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris 
/usr/local/lib/perl5/site_perl/5.005 .) at 
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris/Event.pm line 50.
, Undefined subroutine &desc at foo.pl line 10

end test
Can't locate Event/cancel.pm in @INC (@INC contains: 
/usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 
.) at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/Event.pm line 50.
, Undefined subroutine &cancel at foo.pl line 0


it definitely has to do with the reblessing of the watcher object into
the Stem object. when i removed the bless code it works fine. so somehow
i can't subclass Event so i can use its objects and inherit its
methods. 

uri

#!/usr/local/bin/perl

use strict ;
use Event ;

package Stem::Event ;

sub start_loop {

        Event::loop() ;
}

sub end_loop {

        Event::unloop_all( 1) ;
}

package Stem::Event::Plain ;

use Carp ;
use base qw(Event) ;

sub new {

        my( $class, %args ) = @_ ;

        my( $object, $method, $watcher ) ;

        $object = $args{ 'object' } or croak "No object for plain event\n" ;

        $method = $args{ 'method' } || 'triggered' ;

        $watcher = Event->idle(
                        cb      => [ $object, $method ],
                        repeat  => 0
                ) ;

#       return bless $watcher, $class ;
        return $watcher
}


package Stem::Event::Plain::Test ;

my $evt ;

sub go {

        print __PACKAGE__, " testing\n" ;

        $evt = Stem::Event::Plain->new( 'object' => bless {} ) ;

        Stem::Event::start_loop() ;

        print "end test\n" ;

exit ;
}


sub triggered {

        my( $self ) = @_ ;

        print "success\n" ;

        $evt->cancel() ;

        Stem::Event::end_loop() ;
}


Stem::Event::Plain::Test::go() ;




-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

Reply via email to