in reply to Downloading only new files added to a local path with Perl (FTP)


I'm not 100% certain, but the problem looks like you're not properly interpolating the bash variable list into line 72:

  epoch=$(perl -MFile::stat -e "print stat('$list')->mtime")

So perl is likely trying to execute:

perl -MFile::stat -e "print stat('')->mtime"

Since you don't have a file named '' in your local filesystem, the stat function returns undef, which is why you get the "Can't call method "mtime" on an undefined value at -e line 1" error.

If you put a "set -x" and "set -v" commands in your bash script, you'll be able to see what the expanded command lines expand to in your script, so you can more easily see what bash is telling perl what to do for you.

Also, while I'm happy you're trying to "use strict" and "use warnings", I don't think they'll work well in bash. ;^)


When your only tool is a hammer, all problems look like your thumb.