OK, the easiet way for me to explain this is to show you a line of code that I have at work...

$interface->handler($client)->parse($local_file_name);

My question, I hope, is trivial... 'Which methods are invoked on which objects?'

I have seen examples that piggy-back the '->' operator:

$Person->name('Homer') ->job('safety inspector') ->wife('Marge') ->fav_food('Duff');
Obviosly all the method calls are targeted at the Person object (I mean a job does not have a wife, and we all know that Marge's favorite food is potatoes!) but other times I'll see things like the first line from work where it looks like each call is invoked on the last referenced object.

Does it depend on what each of those calls are returning? i.e. a return of undef forces Perl to make the call on the next previously defined object? Or is there some other rule that I am not aware of?

I have gone through the Object chapter of Programming Perl, 3rd Edition. Feel free to direct me within that text or on-line for an existing explanation. I may have just missed it as a result of my frustration.

the_Don
...making offers others can't rufuse.


In reply to Getting Confused with the '->' operator by the_Don

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.