##using Net::FTP to retrive files from FTP sites like NCBI
    use strict;
    use warnings;
    use Net::FTP;

my $VERSION = 0.1;

print '
In Bioinformatics analysis, we need to download  files (like sequence files with  .FASTA file extension or microsatellite data with .soft extension)
in bulk amount from publicly avilable FTP sites.
Downloading individual files is very tideous and labourous. This script can be used to save little time and a lot of labour.
Simply provide the FTP address and the directory name where your files are located. Specify a file name (example : b12wer.fasta) or 
a category of files with identical file extension (example : for all fasta files type *.fasta or for all zip file type *.zip);

EXAMPLE:
++++++++++
Suppose you accessed the ftp link :ftp.ncbi.nlm.nih.gov/genomes/Protozoa/Theileria_annulata/

it contains alot of data files from the Protozoa, Theileria_annulata like fasta files, ptt files etc.
You have the task to download only the ,.ptt files.

run the script from desired directory and provide the options to the script at commandline.
Please Enter the ftp address: ftp.ncbi.nlm.nih.gov
Please Enter FTP directory:  genomes/Protozoa/Theileria_annulata/
Please Enter User name, (if any):       <----------no login required, so simply press ENter
Please Enter Password:							simply press ENter
Please Specify file extensions or file name to be retrived : *.ptt
Specify the local dierctory name where Files will be stored: PTan_ptt


************* AND the programm will download all ptt files to the PTan_ptt directory*********

Bug report to :
kcm.eid@gmail.com
¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬';


=head1 NAME
RetriveFTP - a PERL script to retrive bulk files from (public) FTP sites

=head1 DESCRIPTION
In Bioinformatics analysis, we need to download  files (like sequence files with  .FASTA file extension or microsatellite data with .soft extension)
in bulk amount from publicly avilable FTP sites.
Downloading individual files is very tideous and labourous. This script can be used to save little time and a lot of labour.
Simply provide the FTP address and the directory name where your files are located. Specify a file name (example : b12wer.fasta) or 
a category of files with identical file extension (example : for all fasta files type *.fasta or for all zip file type *.zip);

EXAMPLE:
++++++++++
Suppose you accessed the ftp link :ftp.ncbi.nlm.nih.gov/genomes/Protozoa/Theileria_annulata/

it contains alot of data files from the Protozoa, Theileria_annulata like fasta files, ptt files etc.
You have the task to download only the ,.ptt files.

run the script from desired directory and provide the options to the script at commandline.
Please Enter the ftp address: ftp.ncbi.nlm.nih.gov
Please Enter FTP directory:  genomes/Protozoa/Theileria_annulata/
Please Enter User name, (if any):       <----------no login required, so simply press ENter
Please Enter Password:							simply press ENter
Please Specify file extensions or file name to be retrived : *.ptt
Specify the local dierctory name where Files will be stored: PTan_ptt


************* AND the programm will download all ptt files to the PTan_ptt directory*********

Bug report to :
kcm.eid@gmail.com

=head1 PREREQUISITES

This script requires the C<strict> module and C<warnings>.  It also requires
C<Net::FTP>.

=pod SCRIPT CATEGORIES

CPAN/Administrative
Scientific/Bioinformatics

=cut
print "\n\nPlease Enter the ftp address:";
    my $ftp_site     = <STDIN>;												
	chomp$ftp_site;
print "\nPlease Enter FTP directory: ";
    my $ftp_dir      =	<STDIN>;										
	chomp$ftp_dir;
print "\nPlease Enter User name, (if any):";
    my $ftp_user     = <STDIN>;
	chomp $ftp_user;
print "\nPlease Enter Password:";
    my $ftp_password = <STDIN>;
	chomp$ftp_password;
print "\nPlease Specify file extensions or file name to be retrived : ";
    my $glob         = <STDIN>;														
	chomp$glob;
    my @remote_files;
print "\nSpecify the local dierctory name where Files will be stored: ";
    my $localDir         = <STDIN>;										
	chomp$localDir;
    my $ftp = Net::FTP->new($ftp_site) or die "Could not connect to $ftp_site: $!";

    $ftp->login($ftp_user, $ftp_password) or die "Could not login to $ftp_site with user $ftp_user: $!";
print "\nConnected to $ftp_site";
print "\ndownloading $glob files";
    $ftp->cwd($ftp_dir) or die "Could not change remote working " . "directory to $ftp_dir on $ftp_site";
    @remote_files = $ftp->ls($glob);
	mkdir("$localDir");
chdir("$localDir");				
    foreach my $file (@remote_files) {
		    $ftp->get($file) or die"cannt download file$file";
		 print "\n $file downloded....."
    }
chdir('..');
    $ftp->quit();