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'}.
Now, if I want to load configs, I might as well dump them too. So I
added the -J switch:
prompt$ cpan -j MyConfig.pl .....
So, I've hacked those bits into the latest cpan, which is not on
github. Right now it's in the dump_config branch:
http://github.com/briandfoy/cpan-script/tree/dump_config
I've not tested it to see if everything else works.
The next step is to add a -oconf switch, or something like that, so I
can do things like replacing only some values:
prompt$ cpan -oconf makepl_arg=foo
That requires a lot more work on the innards though because the script
isn't set up to do fancy argument processing. No idea how I'm going to
do that just yet.