muzakfetch has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone no code today sorry, however my question centers around a good way to confirm that the files I have downloaded via Net::FTP exist in a predefined hash. So that I can confirm if a file is missing. Does anyone have a good method for this. Thanks Always.. Humbly, muzakfetch

Replies are listed 'Best First'.
Re: Hashes and File searches
by jlongino (Parson) on Dec 16, 2001 at 13:12 UTC
    I don't follow you. Maybe you could explain your Net::FTP process. If you already know what files you need, aren't they already in a hash or array? Aren't you looping through that structure and downloading them one-at-a-time? If so, then store/print the resulting ftp status for each as you go.

    Are you downloading every file in a given subdirectory and then trying to figure out if the ones you want are in the lot you've received? If this is the case, you'll probably want to start with an empty target directory, download the files, loop through the filenames (keys) of your hash and test for their existence.

    --Jim

Re: Hashes and File searches
by CharlesClarkson (Curate) on Dec 16, 2001 at 16:39 UTC
    Well if the files you downloaded are in @ftp_files and if your hash has the filenames as keys and is called %file_names, you could do something like:

    my @exceptions = grep ! exists $file_names{$_}, @ftp_files;




    HTH,
    Charles K. Clarkson