Perl6 Net::FTP Sample

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/env perl6

use Net::FTP;

my @locals = (
	"/update/",
);

my @remotes = (
	"/usbip/",
);

my $ftp = Net::FTP.new(:host<192.168.8.179>, :user<ftpup>, :pass<123456>, :passive);

$ftp.login();

for (@locals Z @remotes) -> ($local, $remote) {
	for $local.IO.dir {
		my ($lpath, $rpath);

		$lpath = $_.abspath();
		$rpath = $remote ~ $_.basename();

		if $ftp.put($lpath, $rpath, :binary) {
			say "T\t$lpath ===> $rpath";
			if unlink($lpath) {
				say 'unlink ' ~ $lpath;
			}
		} else {
			say "F\t$lpath =/=> $rpath [ " ~ $ftp.code() ~ ' ' ~ $ftp.msg ~ "]";
		}
	}
}

$ftp.quit();