And to get the file, John Krahn submitted an example below earlier
tonight....

sub get_games_file {
    use Fatal qw(open close);
    use LWP::Simple;
    use HTTP::Status;

    my $URL = 'http://www.mcn.net/~kenpom/cbbgames.txt';
    my $gamefile = '/home/jeff/games/myfile.txt';

    my $rc = mirror( $URL, $gamefile );
    warn status_message( $rc ) if is_error( $rc );
    }


-----Original Message-----
From: Daniel Gardner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 6:37 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: CPAN and Perl


Thursday, December 20, 2001, 11:20:35 PM, Daniel Falkenberg wrote:

> I was just wondering if any one here has any experience with download
> Perl CPAN modules from a Perl script.  I have looked at CPAN.pm but am a
> little confused by this.

> I have tried the following...

> #!/usr/bin/perl -w

> use strict;

> #Check if a module exists... if it doesn't then ask the user with
> <STDIN> Y or N if they want to download and install it.

> Can any one give me a helping hand with this?

nope, don't have any experience with it...

this little snippet should give you some thoughts about the
checking if a module exists part:

   #!/usr/bin/perl -w
   use strict;
 
   print "no CGI\n" unless there('CGI');
   print "no Foo\n" unless there('Foo');
 
   sub there {
        my ($module) = @_;
 
        eval "use $module";
 
        return $@ ? 0 : 1;
   }

you might get some mileage out of schwern's new Module::Info[1]
module, but i haven't used it (yet)

and the Y/N thing might be solved by doing:

  my $input_froom_user = <STDIN>;

or alternatively check out the Term::Readline[2] module for
more power.

1) http://theoryx5.uwinnipeg.ca/CPAN/data/Module-Info/Module/Info.html
2)
http://theoryx5.uwinnipeg.ca/CPAN/data/perl-5.6.1-TRIAL/Term/ReadLine.html

-- 
Best Regards,
Daniel                   [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to