Are you using
Net::FTP?
Because
that its documentation says that
$ftp->ls($dir) returns a directory listing.
Assuming that to be the case, then something like this should work.
use strict;
use warnings;
my @files_to_check = ( 'abc.txt', 'xyz.txt', 'efg.txt' ); # list
+of files to check
my @directory_listing = $ftp->ls($dir);
my %files_on_FTP_server;
foreach my $file (@directory_listing)
{
# extra processing here?
$files_on_FTP_server{$file} = 1;
}
foreach my $file (@files_to_check)
{
if ( ! $files_on_FTP_server{$file} ) { print "File $file is missin
+g\n"; }
}
However, as I do not know the format of
@directory_listing, you might need some extra processing where indicated on line 12.
If
@directory_listing contains a line of info for each file, you'd need a regexp to extract the file from each line, and you'd change line 10 from
foreach my $file (@directory_listing) to:
foreach my $line (@directory_listing)
UPDATE: s/Net::FTP/
Net::FTP/ (ie linkified it)
s/
that/its documentation/
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.