简体   繁体   中英

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!

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM