Reference to object method

Sometimes it's useful to obtain reference to object method.
There is not syntax method to do it like for simple subroutine (\&sub1).
(At least I have not found it).
Use $obj->can($method_name) to do it.

package ClassA;
sub method1 {print "ClassA::method1";}
sub new {my $self={};bless $self,$_[0];$self};
package ClassB;
our @ISA=('ClassA');
sub method2 {print "ClassB::method2";}
package main;
$\="\n";
my $obj=ClassB->new();
print ref($obj);
$obj->method1;
my $method_ref=$obj->can("method1"); #\
$obj->$method_ref;

...

Funny!

In the first - the code is not readable!
Write dividing sections.

In the second, what for rigidly to adhere the message to a class!

In the third explain, sense of the given necessity.

As a whole, it is not bad that the author has written a small manual on objects in PERL.

Thanks!