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: Beginner:
Cwd::abs_path V/S File::Spec->rel2abs

 



sriharsha_12
Novice

Mar 23, 2016, 3:13 AM

Post #1 of 3 (1280 views)
Cwd::abs_path V/S File::Spec->rel2abs Can't Post

I created a link 'date_link.txt' which is a link to 'date.txt' file. I'm trying to get the full path for 'date_link.txt'. When I try the following code,


Code
$f = 'date_link.txt'; 
say 'abs_path(): ' . Cwd::abs_path ($f);
say 'rel2abs(): ' . File::Spec->rel2abs ($f);

Output:
abs_path(): /home/.../test/date.txt
rel2abs(): /home/.../test/date_link.txt


rel2abs gives the required output. I was expecting both rel2abs & abs_path to return the same value. But abs_path returns the path of the real file. Isn't it the way it works?


FishMonger
Veteran / Moderator

Mar 23, 2016, 7:13 AM

Post #2 of 3 (1274 views)
Re: [sriharsha_12] Cwd::abs_path V/S File::Spec->rel2abs [In reply to] Can't Post

abs_path() documentation states:

Quote
Symbolic links and relative-path components ("." and "..") are resolved to return the canonical pathname


The documentation for rel2abs() does not make that statement so there's no reason to think that it would resolve symbolic links.


sriharsha_12
Novice

Mar 27, 2016, 10:49 PM

Post #3 of 3 (1263 views)
Re: [FishMonger] Cwd::abs_path V/S File::Spec->rel2abs [In reply to] Can't Post

Ok. Thanks.

 
 


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

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