Jonathan Peterson [mailto:[EMAIL PROTECTED]] wrote:

>       $self->{rb}->addHook('invoke-on-contents',
\$self->invoke_on_contents);
> I get
> 
> WWW::Robot: SCALAR(0x526e3c) is not a function reference; Ignoring it
> 
> And if I try
> 
>       $self->{rb}->addHook('invoke-on-contents',
> \&{$self->invoke_on_contents});

You need a wrapper for your object method. addHook is expecting a code ref,
but does not know anything about the first (implied) argument, i.e. the
object reference.

I suggest

        $self->{rb}->addHook('invoke-on-contents',
sub {my $foo = $self; $foo->invoke_on_contents});

The intermediary $foo makes the anonymous sub into a closure.


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE (Holdings) Plc or any of its 
subsidiary companies.
-----------------------------------------------------------------------

Reply via email to