如何用perl获取某一文件所在路径?

2025-05-02 07:36:55
推荐回答(1个)
回答1:

用perl获取某一文件所在路径,参考代码如下:

use Cwd 'abs_path';
print abs_path($0)."\n";
man Cwd
NAME
Cwd - get pathname of current working directory
SYNOPSIS
use Cwd;
my $dir = getcwd;
use Cwd 'abs_path';
my $abs_path = abs_path($file);