Code would help.
At a guess your reference to a subroutine in the current
package is a string naming the subroutine, in which
case you are doing a symbolic lookup. That breaks when
the lookup is done in another package. The simplest way
to check that is through use strict, which
will catch the error up front rather than through allowing
subtle bugs in your code and understanding survive.
That said, here is a working example:
package Foo;
use strict; # Always
sub foo {
(shift)->(); # Call the function passed in by reference
}
package Bar;
sub bar {
print "This is bar\n";
}
Foo::foo(\&bar); # Pass a ref to a sub to another package
Note that I am explicitly creating the reference, as
perlref says to, using a \. And it works. |