sventhan
asked on
Case insensitive in Perl while doing FTP.
I've to FTP few .txt files from the remote location and I've the following code to do it.
When I'm reading the remote files (only .txt) I want my perl script to be case insensitive that mean i want to read the file name ends with
.txt, .TXT, .Txt etc...
currently I'm the sub routing mget($ftp,'*.txt') only reading the small case .txt files from the remote location.
Please help.
my $ftp = Net::FTP->new($server, Debug => 0) or die "Connect failed: $@\n";
$ftp->login($userid, $password) or die "Login to the FTP server failed: ",$ftp->message,"\n";
$ftp->ascii;
$ftp->cwd($remotedir) or die "Failed to cd: $ftp->message\n";
mget($ftp, '*.txt'); ## need to look for .TXT or .Txt
sub mget {
my ($ftp, $pattern) = @_;
foreach my $file ($ftp->ls($pattern)) {
$ftp->get($file)
or warn $ftp->message;
}
}
Thanks a lot.
When I'm reading the remote files (only .txt) I want my perl script to be case insensitive that mean i want to read the file name ends with
.txt, .TXT, .Txt etc...
currently I'm the sub routing mget($ftp,'*.txt') only reading the small case .txt files from the remote location.
Please help.
my $ftp = Net::FTP->new($server, Debug => 0) or die "Connect failed: $@\n";
$ftp->login($userid, $password) or die "Login to the FTP server failed: ",$ftp->message,"\n";
$ftp->ascii;
$ftp->cwd($remotedir) or die "Failed to cd: $ftp->message\n";
mget($ftp, '*.txt'); ## need to look for .TXT or .Txt
sub mget {
my ($ftp, $pattern) = @_;
foreach my $file ($ftp->ls($pattern)) {
$ftp->get($file)
or warn $ftp->message;
}
}
Thanks a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again.