Auto-downloading file from CPAN

I

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?

Thanks,
Ilya
 
B

Ben Morrow

Quoth Ilya Zakharevich said:
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
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was NOT [per weedlist] sent to
Ben Morrow
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
 
B

brian d foy

use CPAN;
CPAN::HandleConfig->load;
print for @{ $CPAN::Config->{urllist} }
[/QUOTE]
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top