develooper Front page | perl.beginners | Postings from May 2007

Upload a directory to remote FTP server

Thread Next
From:
Shu Cho
Date:
May 24, 2007 00:26
Subject:
Upload a directory to remote FTP server
Message ID:
20070524151916.DE00.ONIONLAB@gmail.com
Hi list,

I want to upload a directory to a remote FTP server, is there any nice
solution? Here is my script:

#!/usr/bin/perl
use Net::FTP;
use File::Find;

$ftp = Net::FTP->new("host", Port => 1234);
$ftp->login("usr", "passwd");

sub upload_file {
  $ftp->mkdir($File::Find::name, 1) if -d;
  $ftp->cwd($File::Find::name);
  $ftp->put($File::Find::name) if -f;
}

$dir_to_upload = qw(/data);
find(\&upload_file, @dir_to_upload);

$ftp->quit();

It seems my code is ugly:( Can you guys give me some hints?

TIA
-- 
Shu Cho <onionlab@gmail.com>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About