in reply to Re^2: list out all methods of object
in thread list out all methods of object

Your argument applies equally to the OP's original example, so I believe my solution is up to the OP's expectations.

Thanks for the insight on inheritance (++). Always interesting when you learn from doing things wrong.

     Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Replies are listed 'Best First'.
Re^4: list out all methods of object
by GrandFather (Saint) on Jan 25, 2011 at 23:01 UTC
    Your argument applies equally to the OP's original example

    Indeed! In fact my reply to your node was to show the OP why the original question is flawed in the context of "out of the box" Perl. If you add a little explicit inheritance the picture is even more confusing. Consider:

    use warnings; use strict; use Data::Dumper; package testB1; sub PackageB1 { return __PACKAGE__ . "\n"; } sub AnotherB1 { return "Another\n"; } package test; use parent -norequire, qw(testB1); sub new { my ($class) = @_; return bless {}, $class; } sub Package { return __PACKAGE__ . "\n"; } package main; my $obj = test->new (); { no strict 'refs'; print "\nInstance METHOD IS " . Dumper( \%{ref ($obj)."::" }) ; } print $obj->PackageB1 (); { no strict 'refs'; print "\nInstance METHOD IS " . Dumper( \%{ref ($obj)."::" }) ; }

    Prints:

    Instance METHOD IS $VAR1 = { 'AUTOLOAD' => *test::AUTOLOAD, 'ISA' => *test::ISA, 'BEGIN' => *test::BEGIN, 'DESTROY' => *test::DESTROY, 'new' => *test::new, 'Package' => *test::Package }; testB1 Instance METHOD IS $VAR1 = { 'AUTOLOAD' => *test::AUTOLOAD, 'ISA' => *test::ISA, 'PackageB1' => *test::PackageB1, 'BEGIN' => *test::BEGIN, 'DESTROY' => *test::DESTROY, 'new' => *test::new, 'Package' => *test::Package };

    where 'PackageB1' => *test::PackageB1 shows only after the $obj->PackageB1 () call.

    True laziness is hard work