我需要在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 );