Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: create a relative symlink

by soonix (Canon)
on Dec 16, 2019 at 11:22 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-24 09:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found