Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Downloading only new files added to a local path with Perl (FTP)

by roboticus (Chancellor)
on Aug 19, 2020 at 13:26 UTC ( #11120900=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11120900]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2021-01-21 08:05 GMT
Find Nodes?
    Voting Booth?