http://www.perlmonks.org?node_id=653739

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm writting home automation gateway for Linux MEdia Center application. I communicate with automation system via rs232 and have written separate object code for it...
On the other hand, I communicate with LMCE system via TCP socket (separate object code).
Majority of time I do poll of devices status on both interfaces. If any change occurs, then I have to send proper info also on another interface....

Now I'd like for instance use methods of first mentioned object instance in second mentioned object.
I tried simply by sending object A instance as parameter to method of object B and call method but it seems it doesn't work....

Any advice, example ?

Thanks in advance,
regards,
Bulek.
  • Comment on Calling methods of object instance A from object instance B

Replies are listed 'Best First'.
Re: Calling methods of object instance A from object instance B
by erroneousBollock (Curate) on Nov 29, 2007 at 01:53 UTC
    Now I'd like for instance use methods of first mentioned object instance in second mentioned object.
    I tried simply by sending object A instance as parameter to method of object B and call method but it seems it doesn't work....
    If I understand what you're saying, it should work fine.

    $A->methodfoo($B); # methodfoo will call $_[1]->methodbar();

    Could you post a cut-down example of your code that still exhibits the problem? Also, please remember to read Writeup Formatting Tips.

    -David