- 论坛徽章:
- 0
|
原帖由 milk_ 于 2006-3-10 17:05 发表
perl 里如何得到一个文件的绝对路径?
有没有现成的函数?
请指教
If you want your code more portable (in defferent OSs), there is module from CPAN:
File::Spec;
File::Spec::Functions qw/rel2abs/; # relative path to absolute path
Try this:
perl -le 'use File::Spec::Functions qw(rel2abs); print rel2abs(".")'
If your code is just running under Linux/unix, this module in fact uses the command
"pwd" directly. Just like POLOGG's answers.
See more details:
perldoc File::Spec;
perldoc File::Spec::Functions
Best. ulmer |
|