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.
In reply to Re^4: list out all methods of object
by GrandFather
in thread list out all methods of object
by vetrivel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |