http://www.perlmonks.org?node_id=268065


in reply to global source filters

There is always another way to do it in Perl. One of the crazier ones is to put a function reference in @INC as Abigail does at Re: The Future - Managing Modules. The idea would be that when Perl goes to find your module, you would hand it a filehandle which is going to hand Perl filtered text. All of your modules would only be found this way, so they are all filtered with no per module change. (I have seen a tutorial on how to use this feature of @INC, but I can't find it right now.)

In any case the direction that you are headed for sounds exactly like Aspect-Oriented Programming. If you google for that, you can find discussion of how the direction that you are thinking about has turned out for others in other languages. Of a sample set of one person whom I know who has tried it (I only read a couple of articles), all liked it. For more details, ask him.

UPDATE: The Aspect-Oriented Programming that I was talking about and the AOP that mvc mentions below are the same thing. (I think I knew once that there was a Perl implementation...)