in reply to Let a module call a sub of the caller
Should call "foo" after compilation (not during BEGIN). Could the module somehow define an INIT block that calls the sub?
The problem with that is that modules INIT and runtime are still compile time from the perspective of the calling script.
You could run it in an END block, which is also after compilation, but I could imagine that that's too late for your purpose. So I don't know any solution, except via source filters (or maybe evil hijacking of DESTROY subs, depending on when exactly the routine should run).
Speaking of which, what is your purpose? Maybe there's a better solution to it if we know the bigger picture.