Auto-downloading file from CPAN

Discussion in 'Perl Misc' started by Ilya Zakharevich, Sep 21, 2008.

  1. I need to copy a file from CPAN (this file is not a Perl
    distribution!) to the current directory - programmatically. I can
    easily do it if I hardcode a CPAN site. Is there a simple way to do
    this using user-preferences for CPAN access?

    Thanks,
    Ilya
     
    Ilya Zakharevich, Sep 21, 2008
    #1
    1. Advertising

  2. Ilya Zakharevich

    Ben Morrow Guest

    Quoth Ilya Zakharevich <>:
    >
    > I need to copy a file from CPAN (this file is not a Perl
    > distribution!) to the current directory - programmatically. I can
    > easily do it if I hardcode a CPAN site. Is there a simple way to do
    > this using user-preferences for CPAN access?


    use CPAN;
    CPAN::HandleConfig->load;
    print for @{ $CPAN::Config->{urllist} }

    appears to give the list of mirrors, although it's undocumented, it
    writes some rubbish to STDOUT, and it will start a user-configuration
    dialogue if some of the parameters are missing.

    Ben

    --
    It will be seen that the Erwhonians are a meek and long-suffering people,
    easily led by the nose, and quick to offer up common sense at the shrine of
    logic, when a philosopher convinces them that their institutions are not based
    on the strictest morality. [Samuel Butler, paraphrased]
     
    Ben Morrow, Sep 21, 2008
    #2
    1. Advertising

  3. [A complimentary Cc of this posting was NOT [per weedlist] sent to
    Ben Morrow
    <>], who wrote in article <>:
    >
    > Quoth Ilya Zakharevich <>:
    > >
    > > I need to copy a file from CPAN (this file is not a Perl
    > > distribution!) to the current directory - programmatically. I can
    > > easily do it if I hardcode a CPAN site. Is there a simple way to do
    > > this using user-preferences for CPAN access?

    >
    > use CPAN;
    > CPAN::HandleConfig->load;
    > print for @{ $CPAN::Config->{urllist} }
    >
    > appears to give the list of mirrors, although it's undocumented, it
    > writes some rubbish to STDOUT, and it will start a user-configuration
    > dialogue if some of the parameters are missing.


    Hmm, this is exactly the type of mess I would like to avoid. Maybe
    calling CPAN::Config (?) directly would be more approriate? Anyone
    with an experience?

    Thanks,
    Ilya
     
    Ilya Zakharevich, Sep 22, 2008
    #3
  4. Ilya Zakharevich

    brian d foy Guest

    In article <gb73s0$1n8m$>, Ilya Zakharevich
    <> wrote:


    > > use CPAN;
    > > CPAN::HandleConfig->load;
    > > print for @{ $CPAN::Config->{urllist} }


    > Hmm, this is exactly the type of mess I would like to avoid. Maybe
    > calling CPAN::Config (?) directly would be more approriate? Anyone
    > with an experience?


    CPAN::Config->load is now CPAN::HandleConfig->load. There really isn't
    any other way of doing this. If you look inside CPAN.pm you'll see that
    the point of load() is to create $CPAN::Config, a hash reference, and
    everything after that is a hash access.

    I just hacked the cpan script to allow someone to load their own
    config, but that doesn't do much for you because it would be an
    external process. One of the features I've got on my todo list is a
    switch to simply fetch a distro (but not unpack it, etc).

    Adam and Andreas recently (or are close to) added a mirrors list to
    PAUSE so you could download a known file and have easy access to
    various mirrors (easier than MIRRORED>BY, anyway). The Mirror::*
    concept is to be able to quickly find the fastest mirror by pinging a
    bunch of them.

    http://search.cpan.org/dist/Mirror-YAML

    You could also use that list to present to the user. Only recently
    tested good mirrors should be in there.
     
    brian d foy, Sep 22, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. linkswanted
    Replies:
    1
    Views:
    998
  2. carl d.
    Replies:
    1
    Views:
    416
    A. Sinan Unur
    May 10, 2005
  3. Replies:
    5
    Views:
    227
    Randy Kobes
    Oct 12, 2005
  4. Ben Bullock
    Replies:
    12
    Views:
    309
    Ben Bullock
    Jul 8, 2008
  5. SVCitian
    Replies:
    1
    Views:
    1,006
    SVCitian
    Oct 22, 2010
Loading...

Share This Page