Hi,
I am trying to download files using Net::FTP perl module. I am facing problem with downloaded files not able to place in there respective folders. Please need help, I am providing the code below
#!/usr/bin/perl
use Net::FTP;
use File::Copy;
$ftp = Net::FTP->new("ftp.ncbi.nlm.nih.gov", Debug => 0)
or die "Cannot connect to ftp.ncbi.nlm.nih.gov: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
open(FH,"Organism_list.txt");
@organism_name="";
@ftp_id="";
while(<FH>)
{
chomp($);
@records=split("\t",$);
push(@organism_name,$records[0]);
push(@ftp_id,$records[1]);
}
$len=@organism_name;
@ext=("ptt","rnt");
for($i=0;$i<$len;$i++){
$path="/genomes/Bacteria/$ftp_id[$i]/*.";
mkdir("$organism_name[$i]");
@org="";
my $directory="E://projects";
$ftp->cwd($directory) or die "Cannot change working directory ", $ftp->message;
foreach $data(@ext)
{
$retrive=$path.$data;
@files=$ftp->dir($retrive);
foreach (@files)
{
if(/.*(\/genomes.*\.$data)/)
{
print $1,"\n";
push(@org,$1);
}
$ftp->get($1);
}}}
close FH;
Thanking you,
Rajesh