in reply to perl calls unexpected function

So you have a theModule.pm and a X.pm. That are the modules, the files. But for method calls, it's the package, AKA the class, that $self is blessed in which matters, assuming it's an object. You don't mention the packages in the modules at all. Assuming $self is blessed in theModule.pm's package, say, "theModule", then of course the sub theModule::funcB that gets called as a method. If it were blessed in X.pm's class, say "X", then X::funcB would be called. That simple scheme ignores inheritance, i.e. how each package's @ISA array relates, but since each module, er, package, has a funcB method, I don't think it matters much. There must be some relationship, how else would the method funcA in theModule get called in the first place.

You can override normal method lookup, like $self->X::funcB(). I think there recently was a thread on PerlMonks about it. It's an extension to the slightly more orthodox $self->SUPER::funcB() call mechanism.
Update: found it: Invoking method in another package.

Try this, all in one single script — which again shows that it's the package the method is in, that matters, not the source file. The BEGIN block for the assignment to @theModule::ISA is only to make sure it is set when the main code runs, as the module definition is underneath the main code in the script source.

$obj = new theModule; $obj->funcA('own'); $obj->funcA('X'); $obj->funcA('SUPER'); package theModule; BEGIN { @ISA = 'Y'; } sub new { my %self; return bless \%self, shift; } sub funcA { my $self = shift; my $param = shift; print "\nfuncA in theModule got called, param = $param\n"; if($param eq 'own') { $self->funcB; } elsif($param eq 'X') { $self->X::funcB; } elsif($param eq 'SUPER') { $self->SUPER::funcB; } } sub funcB { my $self = shift; print "funcB in theModule is called\n"; } package X; sub funcB { my $self = shift; print "funcB in X is called\n"; } package Y; sub funcB { my $self = shift; print "funcB in Y is called\n"; }
This prints:
funcA in theModule got called, param = own funcB in theModule is called funcA in theModule got called, param = X funcB in X is called funcA in theModule got called, param = SUPER funcB in Y is called