如何获取符号链接文件的绝对路径?

Tre*_*ree 7 perl

#test-> a.pl

my $file = '/home/joe/test';
if ( -f $file && -l $file )  {
    print readlink( $file ) ;
}
Run Code Online (Sandbox Code Playgroud)

如何获取符号链接文件的绝对路径?

vto*_*nen 12

Cwd通过abs_path提供此类功能.

#!/usr/bin/perl -w

use Cwd 'abs_path';

my $file='/home/joe/test';
if( -f $file && -l $file ) {
    print abs_path($file);
}
Run Code Online (Sandbox Code Playgroud)