CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Re: [rahulgupta70] absoulte path for symbolic link: Edit Log



1arryb
User

May 20, 2009, 1:55 PM


Views: 3944
Re: [rahulgupta70] absoulte path for symbolic link

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):

Code
#!/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)


Edit Log:
Post edited by 1arryb (User) on May 20, 2009, 1:56 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives