in reply to Net::FTP usage

You haven't looked at what your target filenames actually are, even though the error message tells you that they are bad. Do:

for my $target (@array) { print "Trying to store [$target]\n"; };

Then you will see that each target filename still has a newline appended. See chomp on how to remove them, or consider just stripping all trailing whitespace:

for my $target (@array) { $target =~ s/\s+$//; print "Storing [$target]\n"; $ftp->put( $target ); };

Replies are listed 'Best First'.
Re^2: Net::FTP usage
by kafkaf55 (Acolyte) on Aug 13, 2010 at 14:04 UTC
    It is showing me the filename that I expect, just like when I was debugging. Like the first file is sudolog_2010Jul_Infodevl. Now is says "Cannot open Local file sudolog_2010Jul_Infodevl: A file or directory in the path does not exist pointing to the $ftp->put statement. Earlier in the code I cd to the local directory. Should that still exist for this FTP? Ken

      You never call chdir, so you never change your working directory for your Perl script.

      Maybe you want to read about glob instead of shelling out to write the entries of a directory into a file?

      Also, I still don't believe you that you do not have whitespace at the end of the elements of @array.

      use File::Glob 'bsd_glob'; my @files = bsd_glob "$tempdir/sudolog*"; print "Found file [$_]\n" for @files;

      ... will read all the files named sudolog* from the directory given in the $tempdir variable.

      Based on your die statements, I don't think that the issue is with the $ftp->put line. The error message that you mentioned ("Cannot open Local file sudolog_2010Jul_Infodevl: A file or directory in the path does not exist") looks like the die statement from where you tried opening the file.

      I agree with Corion about the problem being that you're in the wrong directory. Unless your Perl script is run in the same directory as the 'lsfiles' file that you're trying to create, the open command will look in the path that the Perl script was invoked from and will fail to find it.