my ($addr, $usr, $pwd, $ascii, $active, $timeout) = @_;
my $ftp;
# Set up new FTP with active mode and user-specified timeout...
if ($active and $timeout)
{
$ftp = Net::FTP -> new ($addr, Passive => 0, Timeout => $timeout)
or die "Failed to connect to FTP (w/ active, timeout): $addr";
}
# Login to new FTP
$ftp -> login ($usr, $pwd)
or die "Failed to login to FTP: " . $ftp->message;
# Set ASCII or binary transfer modes
if ($ascii) { $ftp -> ascii(); }
else { $ftp -> binary(); }
print "LOGIN: $addr\n";
return $ftp;
}
有人可以解釋一下上面的操作嗎?它登錄到ftp然後返回它?它實際上返回了什麼?這是用於上傳還是下載?ftp請求返回什麼(Perl)
FTP並不是真正面向請求的,它基於一個連接,然後你發送命令。您發佈的代碼似乎只是設置了一個連接以供進一步使用。 – millimoose