Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: create a relative symlink

by soonix (Canon)
on Dec 16, 2019 at 11:22 UTC ( #11110236=note: print w/replies, xml ) Need Help??


in reply to Re^2: create a relative symlink
in thread create a relative symlink

to create a working relative link, I need to do a chdir first
That 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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-11-28 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?