Perl 使用 Net::FTP 从 FTP 上下载文件

#!/usr/bin/perl

use Net::FTP;

$ftp = Net::FTP->new("ftp.cpan.org", Timeout => 30)
or die "Could not connect.\n";

$username = "anonymous";
$password = "";

$ftp->login($username, $password)
or die "Could not log in.\n";

$ftp->cwd('/pub/CPAN');
@ls = $ftp->ls();                          #得到目录下所有文件,便于批量下载

$remotefile = "CPAN.html";
$localfile = "file.txt";

$ftp->get($remotefile, $localfile)    #上传为put函数
or die "Can not get file.\n";
posted @ 2011-06-10 09:19  ACE封印  Views(540)  Comments(0Edit  收藏  举报