Author: Brian D FoyBrian D Foy Date: Sep 17, 2008 18:52
To bring everyone up to speed, someone asked me to modify the cpan
script so it would load a one-time use configuration file.
That's a bit difficult to do inside CPAN.pm because the module is
hard-coded to look for CPAN/MyConfig.pm in @INC (and it shoves ~/.cpan
in there for you).
The use case looks like:
prompt$ cpan -j MyConfig.pl .....
Inside MyConfig.pl, you do something that populates $CPAN::Config when
it loads. It's possible to do that not when it loads, but the easiest
thing is to just take a file in the right format. $CPAN::Config is a
global variable, and that's just the way it is, so I'm leaving all of
that complexity in whatever MyConfig.pl is.
Now comes the tricky part. CPAN.pm has several entry points, and they
first check that the config was loaded before they do their thing.
CPAN::HandleConfig->load (formerly CPAN::Config->load) checks that
$CPAN_loaded is true. If it's not, it calls require_myconfig_or_config,
which looks in %%INC for $INC{'CPAN/MyConfig.pm'}.
|