简体   繁体   English

如何使用Net :: FTP获取与模式匹配的文件?

[英]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? 如何使用Net::FTP获取与模式匹配的文件?

Basically what I want to do is: 基本上我想做的是:

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

Should match all files starting with test and do a get() . 应该匹配所有以test开头的文件,并执行get()

Thanks for any help! 谢谢你的帮助!

Try this solution from perlmonks.org. 从perlmonks.org尝试此解决方案 Essentially do a remote ls, filter out what you don't want with grep , then fetch the files. 本质上是执行远程ls,使用grep过滤掉不需要的内容,然后获取文件。

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

BTW, this took about 10 seconds to find with Google "net::FTP mget" 顺便说一句,这用了大约10秒钟的时间才能通过Google找到“ net :: FTP mget”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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