I think i may have read this question in a more generalized way then the orriginal poster was looking for, I started thinking:

How can you confirm that an object impliments a given method?

Which seems really usefull to me in a language without strict typing, or interfaces. Developers can provide APIs in which they say "you can pass me ny object of any class, as long as it impliments the following methods..." and the API can do "friendly" sanity checking of the objects to make sure they impliment all the neccessary methods prior to doing any processing, and generate a "friendly" error and return -- instead of just letting the Interpreter spit out an error msg and keep on processing.

But i honestly can't think of anyway straightforward way to do a check like this in perl. Looking in the Symbol table seems like a good approach but it doesn't take into account subclassing, so we'd need to "walk the symbol table" .. but i'm affraid my typeglob / symbol table knowledge doesn't extend to dealing with superclass relationships.

So i propose to extend the orriginal question be extended. Given a package name (as returned by the ref method) what's the best way to determing if "foo" is a valid method name for that package ?


In reply to Re: detecting improperly called subroutines by hossman
in thread detecting improperly called subroutines by drfrog

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.