[Discuss] Perl OO question
Tom Metro
tmetro-blu at vl.com
Wed Nov 16 16:34:58 EST 2011
Derek Martin wrote:
> I...have two implementations of a Perl module, and
> I want to compare them programmatically.
I would take the approach of running Perltidy[1] on both, followed by
diff or other text processing of your choice. (For example, once you
have methods formatted consistently, a simple grep can list all the
methods in a file.)
dynamically generated methodsThis isn't perfect if your two modules
differ radically, as you can have , or an implementation that is spread
across multiple modules using inheritance.
1. http://perltidy.sourceforge.net/
> Is there a way to do this *in code* *in Perl*?
I see you ran across how to dive into the symbol table.
> The namespace is polluted by members of other imported modules used
> within that one, a fact which I have very little control over.
Using an OO framework like Moose avoids this, but that doesn't help you
if the code you are analyzing doesn't use it.
OO in Perl 5 is "glued on" rather than native, unlike Perl 6, and this
becomes evident when you start introspecting objects.
> I was also reminded that I (still) hate Perl.
Perl makes easy stuff convenient, and hard stuff possible. What you were
looking to do is out of the realm of what's typical.
-Tom
--
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/
More information about the Discuss
mailing list