cosimo has asked for the wisdom of the Perl Monks concerning the following question:
Inspired by adamk at last YAPC::Europe, I'm trying to do an "evil" experiment. I want to change the required module names on the fly. Suppose that I have:
require 'My/Module.pm'; print My::Module::foo();
Ok. Now, what I want is to add my own pragma. And if I do this, I want My::Module to be replaced with Another::Module. Something like:
use my_evil_pragma; # Here this should really load 'Another/Module.pm', # possibly using my_evil_pragma::replace_name($mod) require 'My/Module.pm'; print Another::Module::foo();
I originally tried with use, but I don't remember why I fell back on require. Anyway, it looks like I can't find a way to properly override CORE::GLOBAL::require to do what I want.
Or, is there some other way to achieve this?
... and no, it's not production code, only some experiment ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Yes, you can override *CORE::GLOBAL::require
by jand (Friar) on Sep 11, 2008 at 18:36 UTC | |
Re: Override *CORE::GLOBAL::require. Is it possible?
by jettero (Monsignor) on Sep 11, 2008 at 16:48 UTC | |
Re: Override *CORE::GLOBAL::require. Is it possible?
by moritz (Cardinal) on Sep 11, 2008 at 16:56 UTC | |
Re: Override *CORE::GLOBAL::require. Is it possible?
by jdrago_999 (Hermit) on Sep 11, 2008 at 17:40 UTC |
Back to
Seekers of Perl Wisdom