joybee2015 has asked for the wisdom of the Perl Monks concerning the following question:
In /var/tmp, I have file1, file2 and flink and flink ->file1, I need to get the absolute path of file1, which is /var/tmp/file1 to compare it with string fp1, the problem is that I cant get absolute path, how to solve the issue?
#!/usr/bin/perl my $lpath = /var/tmp/flink; my $fp1 = /var/tmp/file1; my $realpath =readlink($lpath); #which returns file1; my $absolutepath = abs_path($realpath); #returns ~/perl/file1, where ~ +/perl is where my perl script is, not correct if (-e $realpath) { print "$realpath exist\n"; } else { print "not exist\n"; #which is not true }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: symbolic link and absolute path
by ikegami (Patriarch) on Aug 07, 2017 at 20:39 UTC | |
|
Re: symbolic link and absolute path
by 1nickt (Canon) on Aug 07, 2017 at 20:53 UTC | |
by joybee2015 (Novice) on Aug 09, 2017 at 05:26 UTC |