On 4/7/06, Ricardo SIGNES <[EMAIL PROTECTED]> wrote: > * demerphq <[EMAIL PROTECTED]> [2006-04-07T08:32:35] > > Actually afaik there is no good way to find out what dereferencing > > operators an object supports. The best that I know of is reftype(), > > but that only tells you the objects underlying intrinsic type, it > > doesnt tell you if you can dereference the type other ways. > > I actually just ranted about this recently in my journal: > > http://use.perl.org/~rjbs/journal/29229 > > This code should be relatively demonstrative: > > sub _CALLABLE { > (Scalar::Util::reftype($_[0])||'') eq 'CODE' > or > Scalar::Util::blessed($_[0]) and overload::Method($_[0],'&{}') > ? $_[0] > : undef; > }
My general approach to this is to just ignore it. I dont write or use parameter validation routines except if the routine could be potentially harmful. Otherwise I just let Perl handle it. It seems to me that usually thats a better approach than doing parameter validation all over the place. But i can see how the code above could be pretty useful. Say for a potentially destructive routine that you cant just execute to see if its executable. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"