What I did was write a quick script to send STDERR to a log file. Things went astray again and this is the message that I got. fileparse(): need a valid pathname at ftpData.pl line 312 I am using fileparse (File::Basename) to disregard any file extensions in directory comparisons and to remove the existing extension when the file is copied and renamed with a different extension, like so:
#Disregard file extension in comparison:
foreach my $item (@wrkDirList) {
my ( $fileName, $filePath, $fileExt ) = fileparse($item, qr/\.[^.]*/);
$item = $fileName;
}
and foreach $item (@filesToRetrv) {
my ( $fileName, $filePath, $fileExt ) = fileparse($item, qr/\.[^.]
+*/);
if (rename($item, $fileName)) {
push (@filesToMove, $fileName);
} else {
print LOG "Rename failed for $localName to $fileName\n";
}
}
So, and correct me if I am wrong, somewhere along the line it looks like fileparse is getting passed an empty filehandle? I'm not really sure how this could happen. The STDERR message seems to be occurring at the second instance of fileparse (the one working on @filesToRetrv). Here is a little snippet with info about this array and what goes into it: foreach $fileToGet (@matches) {
my $remoteFileSize = $ftp->size($fileToGet);
$localFileName = "$fileToGet".".xxx";
$ftpReturnVar = $ftp->get($fileToGet, $localFileName);
$localFileSize = (stat "$workingDir/$localFileName")[7];
if ($remoteFileSize == $localFileSize) {
push (@filesToRetrv, $ftpReturnVar);
} else { ... }
}
Any ideas? Thanks for the help! |