Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found