Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

cpan home

by equick (Acolyte)
on Feb 16, 2011 at 11:15 UTC ( #888494=perlquestion: print w/ replies, xml ) Need Help??
equick has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to start perl -MCPAN -e shell pointing at a different config file? I have a floating home directory so when I log on to a solaris box, I have the same home directory as when I log on to a linux box. This causes issues when running cpan, because the environments differ.

Thanks for any help,

Ed.

Comment on cpan home
Re: cpan home
by Corion (Pope) on Feb 16, 2011 at 11:22 UTC

    There seems to be no documented way, but looking at CPAN::HandleConfig::require_myconfig_or_config, the following could work (likely you want that as a separate script or alias):

    perl -e "require '~/.cpan/MyConfig.$(uname).pm'; $INC{'CPAN/MyConfig.p +m'}=1" -MCPAN -eshell

    Likely, your ~/.cpan/MyConfig.linux.pm should look like

    package CPAN::MyConfig; ... options as in the common CPAN::MyConfig
      Thanks for the quick reply. I gave that a try but hit a slight error.
      perl -e "require '~/.cpan/CPAN/MyConfig.$(uname).pm'; $INC{'CPAN/MyCon +fig.pm'}=1" -MCPAN -e shell Semicolon seems to be missing at -e line 1. syntax error at -e line 1, near "}=" Execution of -e aborted due to compilation errors.
        Put it in a file
        $ cat mcpan #!/usr/bin/perl -- require $INC{'CPAN/MyConfig.pm'} = ...; require CPAN; CPAN::shell();
Re: cpan home
by roboticus (Canon) on Feb 16, 2011 at 11:35 UTC

    equick:

    In the CPAN docs, it mentions that you can override values in CPAN/Config.pm by putting a file in $HOME/.cpan/CPAN/MyConfig.pm. Perhaps you can then place a bit of code in MyConfig.pm to detect your login and perform the appropriate initializations.

    # MyConfig.pm # Stuff common to all configurations $CPAN::Config = { 'applypatch' => q[], # bunch of junk snipped out }; if ($Config{osname} eq 'foo') { $CPAN::Config->{build_dir} = '/work/builds/foo'; } elsif ($Config{osname} eq 'bar') { $CPAN::Config->{build_dir} = '/work/builds/foo'; } 1;

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: cpan home
by tinita (Parson) on Feb 16, 2011 at 12:06 UTC
    try the -j option with the cpan script:
    cpan -j some/other/file Module::Foo
      Hmm, is -j a new option?
      $ cpan -j some/other/file Module::Foo Unknown option: j LWP not available $ cpan -v cpan script version 1.03 CPAN.pm version 1.7602
        yes, it's quite new, but OTOH, it's in version App::Cpan 1.57 which is from december 2009.
        I just knew about the option because I was one of the people who requested this feature. Unfortunately I don't see it in the changelog so I don't know in which version it was introduced.

        update: s/App::cpan/App::Cpan/ (although the linked cpan search is case insensitive, but anonymous monk complained)
        The -j option exists in the current release (5.12.2) on Perl documentation. Refer to cpan. You could search through the perldelta's if you want to know when this feature was added.

        I'm on perl 5.12.2:

        cpan -v cpan script version 1.5701, CPAN.pm version 1.9456

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://888494]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-09-03 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls