Perl获取脚本执行的目录

时间:2013-11-23 01:17:30

标签: perl

我在/u/meee/ws 我正在执行/u/bin/execd

use Cwd qw ( abs_path );
print abs_path($0); #gives the location of the script, /u/bin/execd 

我能做些什么才能获得/u/meee/ws

1 个答案:

答案 0 :(得分:1)

use Cwd;
my $dir = getcwd;
use Cwd 'abs_path';
my $abs_path = abs_path($file);

第一个会是吗?

相关问题