Bod:

The second function, access_token, is fetching a value from the object referenced by $self, so it's pretty straightforward.

The request function is a *little* more subtle: As you notice, it calls the access_token function, but the result from that call is treated as a reference to an object that has a request function. Note that the object referenced by access_token is *not* necessarily the same class or object found in the request function you posted. So in order to understand what's happening, you'll need to figure out where the access_token member in the object is being set, so you can figure out what sort of object is being accessed.

Sometimes when tracking through the code is a bit annoying, I'll do something like a quick edit of the module:

$ # make a copy of the module so I don't mess it up $ cp /home/shoples1/perl5/lib/perl5/LWP/Authen/OAuth2.pm foo.pm $ vi /home/shoples1/perl5/lib/perl5/LWP/Authen/OAuth2.pm . . . edit the request subroutine to look like: sub request { my ($self, $request, @rest) = @_; use Data::Dumper; my $temp = $self->access_token; print "access token is: ", Dumper($temp), "\n"; return $temp->request($self, $request, @rest); } $ # run the project so I can see what I'm looking for $ perl t.pl blah, blah, blah access token is:$VAR1 = bless( { 'baz' => 'boom', 'foo' => 'bar' }, 'Barsoom!' ); blah, blah, blah $ # put things back so I don't cause more problems for myself $ cp foo.pm /home/shoples1/perl5/lib/perl5/LWP/Authen/OAuth2.pm

Hope this helps!

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Subs calling themselves by roboticus
in thread Subs calling themselves by Bod

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.