in reply to Net::FTP get function question

This is the laziest way that I know. First, create the directory where you want to store the files. Next, cd to that directory. For an example, try this:
#!/usr/bin/perl use strict; use warnings; use Net::FTP; use constant HOST => 'ftp.cpan.org'; use constant DIR1 => '/pub/CPAN/authors'; use constant FILE1 => '01mailrc.txt.gz'; use constant DIR2 => '/pub/CPAN/modules'; use constant FILE2 => '02packages.details.txt.gz'; use constant FILE3 => '03modlist.data.gz'; my $ftp = Net::FTP->new( HOST, Debug => 1, Passive => 1, Timeout => 1 ); $ftp->login('anonymous'); $ftp->cwd(DIR1); $ftp->binary; $ftp->get(FILE1); $ftp->cwd(DIR2); $ftp->get(FILE2); $ftp->get(FILE3); $ftp->quit;

Replies are listed 'Best First'.
Re^2: Net::FTP get function question
by xiaoyaotan (Initiate) on Mar 11, 2010 at 23:20 UTC
    thanks! actually, i found a easier way, just as Illuminatus said, in the the second argument, LOCAL_FILE, i just have to indicate the whole path where i want to save the file and append the file name after it, it would work.

    my code: <code> $ftp -> get ($file_name, "/home/xiaoyao/Desktop/updating_files/" . $file_name ) or die "get $file_name failed: " . $ftp -> message() ; <code>

    Thanks any way.