[Discuss] Perl OO question

Derek Martin invalid at pizzashack.org
Tue Nov 15 17:50:54 EST 2011


On Tue, Nov 15, 2011 at 09:35:37AM -0800, Dan Kressin wrote:
> I haven't tried it, but what about this?
> 
> http://search.cpan.org/~adamk/Class-Inspector-1.24/lib/Class/Inspector.pm

Well...  This wouldn't have really worked for me because the
environment in which I need to do this is somewhat tightly
constrained.  Thanks for the suggestion though.

A coworker was able to point out the flaw in my approach: The methods
are contained in the package's namespace (which is itself a hash),
rather than the instance's hash.  So you could get them by doing
something like:

  @methods = keys(%{MyObject::});

As it turns out though, this isn't what I needed either... The
namespace is polluted by members of other imported modules used within
that one, a fact which I have very little control over.  Also while
the calls were all identical in form, the return values were not of
the same type/structure.  So in the end, I had to write
method-specific code to test each one individually, regardless.

I did learn something though!  So all is not lost.  I was also
reminded that I (still) hate Perl.

Thanks again.

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.



More information about the Discuss mailing list