in reply to list out all methods of object

How about:
print "Instance METHOD IS " . Dumper( \%{ref ($current_Time )."::" } +) ;
Output:
Instance METHOD IS $VAR1 = { 'hour' => *Time::tm::hour, 'AUTOLOAD' => *Time::tm::AUTOLOAD, 'struct' => *Time::tm::struct, 'yday' => *Time::tm::yday, 'mon' => *Time::tm::mon, 'BEGIN' => *Time::tm::BEGIN, 'new' => *Time::tm::new, 'mday' => *Time::tm::mday, 'wday' => *Time::tm::wday, 'min' => *Time::tm::min, 'isdst' => *Time::tm::isdst, 'DESTROY' => *Time::tm::DESTROY, 'croak' => *Time::tm::croak, 'import' => *Time::tm::import, 'confess' => *Time::tm::confess, 'sec' => *Time::tm::sec, 'carp' => *Time::tm::carp, 'ISA' => *Time::tm::ISA, 'VERSION' => *Time::tm::VERSION, 'year' => *Time::tm::year };

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

Replies are listed 'Best First'.
Re^2: list out all methods of object
by GrandFather (Saint) on Jan 25, 2011 at 06:27 UTC

    That may not help the OP much as it doesn't actually provide a list of methods in the sense that the word 'method' is usually used (a 'function' called with reference to an object instance). Consider the following trivial class with no methods in what I am claiming is the conventional sense:

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

    Prints:

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

    'AUTOLOAD' and 'DESTROY' are inherited methods. 'new' is a class method and 'Package' is a function in the 'test' package. If you add base classes the results are even more confusing with the ref trick only showing 'methods' in the base classes that have been called already.

    True laziness is hard work
      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

        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