perl脚本的目录
http://stackoverflow.com/questions/5703705/print-current-directory-using-perl?rq=1 ? 1) The following get the script's directory,which is not the same as the current directory. It's not clear which one you want. use Cwd qw( abs_path ); useFile::Basename qw( dirname ); say dirname(abs_path($0)); or usePath::Class qw( file ); say file($0)->absolute->dir; or useCwd qw( abs_path ); The middle one handles symlinks different than the other two,I believe. ? 2) To get the current working directory (pwd on many systems),you could use cwd() instead of abs_path: useCwd qw(); Or abs_path without an argument: useCwd qw(); See the?Cwd docs?for details. To get the directory your perl file is in from outside of the directory: useFile::Basename qw(); See the?File::Basename?docs for more details. ? 3) You could use? use FindBin '$RealBin';
? 完! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |