How to split ?

Tags: 
Description: 
!/usr/bin/perl

use strict;
use warnings;
use Net::FTP;

my $ftp_server = "centos.schlundtech.de";
my $glob = '*';
my @remote_files;
my $file_attr;

my $ftp = Net::FTP->new("$ftp_server", Debug => 0)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/centos")
or die "Cannot change folder ", $ftp->message;
# $ftp->pwd()
# or die "Cannot display full path ", $ftp->message;
# $ftp->ls("/centos")
# or die "Cannot change working directory ", $ftp->message;
# $ftp->get("TIME")
# or die "get failed ", $ftp->message;

#Current dir
my $curr_dir = $ftp->pwd();

@remote_files = $ftp->dir();

foreach my $file_line (@remote_files) {
my @file_line = split(/\s+/, $file_line);
# my $dir = $file_line[7];
print "$file_line[8] \n";

if ( $file_line[0] =~ /^d/ )
{
my $dir = $file_line[8];
print "Directory: $curr_dir/$dir \n";
}
elsif ( $file_line[0] =~ /^l/ )
{
print "Symbolic link: $file_line \n";
}
else
{
print "Plik: $file_line \n";
}
}

$ftp->quit;

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Fill in the blank.