>> 2) What I do with the data will obviously depend on the program using
>> my
>> object, but would probably be things like update the screen (Term, TK,
>> Win32), or to send instructions to a control system (e.g. throw points
>> on
>> model railway).
>>
>> What is the best method to pass control back to the program from
>> within a
>> method?
>
> I don't think I understand this question.  The obvious answer to me is
> return (exit the method).  Control will pass back to the caller at this
> point, as it always does.  If I misunderstood, please try explaining it
> again.

I expect you are looking for callbacks here.  The caller passes in a sub
(reference) which you call from within the method.

$obj->meth(sub { my ($oomph, $time) = @_; print "Oomph is $oomph at $time" })

and in the module

sub meth
{
    my $self = shift;
    my ($callback) = @_;
    my ($oomph, $time) = ...
    $callback->($oomph, $time);
}

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to