In your first example: $interface->handler($client)->parse($local_file_name); the method that is called is the parse method of the object referenced by: $interface->handler($client). The arrow operator associates left to right, hence the above result.

Your second example

$Person->name('Homer') ->job('safety inspector') ->wife('Marge') ->fav_food('Duff');

seems to be just plain weird. I might be (and almost certainly am) missing something - the same thing as you in that case :) - but I read this as "execute the method fav_food on the object returned by executing wife on the object returned by executing job on the object returned by executing name on the thingy referenced in $person" (arguments left out to save what little shreds of clarity remaining). Beats me. Help.

CU

Robartes -


In reply to Re: Getting Confused with the '->' operator by robartes
in thread 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.