Chris
Chris

Reputation: 3043

How can I use Net::FTP to get a file matching a pattern?

How can I use Net::FTP to get a file matching a pattern?

Basically what I want to do is:

$ftp->get("test*");

Should match all files starting with test and do a get().

Thanks for any help!

Upvotes: 1

Views: 2679

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

Try this solution from perlmonks.org. Essentially do a remote ls, filter out what you don't want with grep, then fetch the files.

$ftp->get($_) for grep /\.txt$/, $ftp->ls;

BTW, this took about 10 seconds to find with Google "net::FTP mget"

Upvotes: 6

Related Questions