To the best of my knowledge there is no way to do what you want other than through some kind of heuristic. The simplest of which is to check whether the first argument is reasonable. Another trick would be to have the name of the class not match the name of the file (for instance it is a simpler version of it) but also offer functions that can be exported from Exporter using @EXPORT_OK (which is set by a query for available functions). Then tell people they can import functions or call methods, and they will be distinct because they are in different packages.

However all of that said, I would step back and ask why you want to do this. If you succeed it has to be through some complex trickery which makes your code harder to understand, and I don't see that the flexibility adds that much for the person using this code. In other words in your position I probably would simply not add the feature, and then I would call the problem solved.

BTW some tips. Creating a new connection for every single function call is painfully slow so I hope your function is returning the same connection each time. If you cannot find a method, you should croak or confess, not return a message. In fact I don't see that you will ever reach that error since if your table meth_tbl has a body field, you will always have that key in your hash.


In reply to Re (tilly) 1: AUTOLOAD detecting the type of method call. by tilly
in thread AUTOLOAD detecting the type of method call. by metcals1

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.