in reply to AUTOLOAD detecting the type of method call.

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.

  • Comment on Re (tilly) 1: AUTOLOAD detecting the type of method call.