[Discuss] Perl OO question

Derek Martin invalid at pizzashack.org
Mon Nov 14 20:06:11 EST 2011


I, for whatever reason, have two implementations of a Perl module, and
I want to compare them programmatically.  I thought it would be easy
enough to get the methods of the object with code similar to this:

my $o = MyObject->new();
foreach $method (sort(keys(%$o))){
    debug("method = $method\n");
    if (ref($o->{$method}) eq "CODE"){
      print("method $method found\n");
    }
}

But this does not work, as it only prints out the attributes (i.e. the
non-code members) of the object, even in the debug() call (which, if I
defined it here, would just be a subroutine that calls print with its
args and potentially some other info).

Is there a way to do this *in code* *in Perl*?

Thanks

-- 
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