to create a working relative link, I need to do a chdir firstThat would be the easiest way. However, it seems that you simply need to calculate the relative link (relative to the folder/directory where the symlink-to-be shall reside), e.g. with Path::Tiny->relative()
my $newname="/home/script/data/archive/currentfile"; my $targetfile="/home/script/data/archive/infofile-2019-12-16"; # untested use Path::Tiny 'path'; my $newdir = path($newfile)->parent(); my $linktarget = path($targetfile)->relative($newdir); print ":$linktarget:\n"; symlink $linktarget, $newname;
In reply to Re^3: create a relative symlink
by soonix
in thread create a relative symlink
by Skeeve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |