Ch said:
Added the case you might be thinking of: ...??
#!/usr/bin/perl
use strict;
use warnings;
package Object;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "Object::method invoked on $self with args @_\n";
}
package DerivedObject;
our @ISA = qw/Object/;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "ObjectDerived::method invoked on $self with args @_\n";
}
package main;
my $object = Object->new;
my $object_derived = DerivedObject->new;
my $method_ref = $object->can('method');
my $method_name = 'method';
my @args = qw/foo bar/;
for ($object, $object_derived, 'nothing'){
$method_ref->($_,@args);
$_->$method_ref(@args); # function call
$_->$method_name(@args); # method call
$_->method(@args);
print "\n";
}
Christoph