Perl 中将文件复制到尚未创建的目录树的最佳方法是什么?
在 Perl 中将文件复制到尚未创建的目标目录树的最佳方法是什么?
类似的东西
copy("test.txt","tardir/dest1/dest2/text.txt");
不会工作,因为目录 tardir/dest1/dest2 还不存在。 在 Perl 中创建目录进行复制的最佳方法是什么?
What is the best way in Perl to copy files to a yet-to-be-created destination directory tree?
Something like
copy("test.txt","tardir/dest1/dest2/text.txt");
won't work since the directory tardir/dest1/dest2 does not yet exist. What is the best way to copy with directory creation in Perl?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
File::Copy::Recursive::fcopy() 不是-core 但将 File::Path::mkpath() 和 File::Copy::copy() 解决方案组合成更短的内容,并保留与 File::Copy 不同的权限。 它还包含其他漂亮的实用功能。
File::Copy::Recursive::fcopy() is non-core but combines the File::Path::mkpath() and File::Copy::copy() solution into something even shorter, and preserves permissions unlike File::Copy. It also contains other nifty utility functions.
请参阅其他答案以进行复制,但要创建目录 Path::Class 非常好用:
See the other answers for doing the copying, but for creating the directory Path::Class is very nice to use: