
1arryb
User
May 20, 2009, 1:55 PM
Post #2 of 4
(6226 views)
|
Re: [rahulgupta70] absoulte path for symbolic link
[In reply to]
|
Can't Post
|
|
Hi rahu, Get the abs_path of the directory component to avoid traversing the link at the file level (of course, this won't work if '../../' is also a link):
#!/usr/bin/perl # use strict; use warnings; use Cwd qw(abs_path); use File::Basename; my $link = $ARGV[0]; die "usage: $0 <link_name>" unless $link; unless (-l $link) { print "WARNING: $link isn't a symlink. This won't prove anything.\n"; } print abs_path(dirname($link)) . '/' . basename($link) . "\n"; Cheers, Larry
(This post was edited by 1arryb on May 20, 2009, 1:56 PM)
|