如何在Perl中构建与OS无关的文件路径,包括可选的Windows驱动器号
发布时间:2020-12-15 21:17:13 所属栏目:大数据 来源:网络整理
导读:我需要在Perl脚本中构造一个文件路径.我应该使用哪个路径分隔符来允许我的脚本在Windows和Unix上运行? 请记住,Windows需要驱动器号. 解决方法 你想要 File::Spec的猫道: catpath() Takes volume,directory and file portions and returns an entire path.
我需要在Perl脚本中构造一个文件路径.我应该使用哪个路径分隔符来允许我的脚本在Windows和Unix上运行?
请记住,Windows需要驱动器号. 解决方法
你想要
File::Spec的猫道:
catpath() Takes volume,directory and file portions and returns an entire path. Under Unix,$volume is ignored,and directory and file are concatenated. A '/' is inserted if need be. On other OSes,$volume is significant. $full_path = File::Spec->catpath( $volume,$directory,$file ); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |