in reply to symbolic link and absolute path

You don't need readlink. Simply use abs_path.

$ cd /Users/nick $ echo 'hi' > /tmp/foo $ ln -s /tmp/foo ./foo $ perl -MCwd=abs_path -E 'say abs_path("./foo")' /private/tmp/foo $ perl -MCwd=abs_path -E 'say abs_path("/Users/nick/foo")' /private/tmp/foo


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: symbolic link and absolute path
by joybee2015 (Novice) on Aug 09, 2017 at 05:26 UTC

    Thanks ikegami and lnickt for the help. Using abs_path directly without readlink did solve the problem.

    And sorry for the bug in my program. I posted on the windows and I ran my code on linux. So I just typed the code here without checking. I indeed used Cwd qw(abs_path).