|go ahead... be a heretic|
Re: Omitted subroutine argumentsby techcode (Hermit)
|on Mar 20, 2011 at 20:51 UTC||Need Help??|
If you really want to get funky you can do that by analyzing @_ array and possibly even it's contents and type/content of stuff in it.
Before people say that it's bad idea - I agree that it usually is a bad idea - but sometimes it just makes sense. Like one module I'm working on - in which I'm trying to avoid as much of additional code that you have when working with DB - but allowing you a lot of customization - and not taking you away from SQL in the usual ORM way.
This allows you to call this method using any of these ways:
Yes I could have used hash(ref) based params - but I wanted to avoid them because that would add what I found as unnececary cruft - that I am trying to avoid in the first place - looking something like:
And to repeat, in general it's a bad idea, but IMHO in this case it does make sense as it replaces a familiar structure of SELECT _fields_ FROM _dbname_._tablename_ WHERE _id_field_ = _id_value_; (added bonus that DB can be a different connection/DBH) so it's relatively easy to remeber ordering and uses the most usual defaults if you ommit them.
In your case it could be something like: