brian d foy
brian d foy

Reputation: 132858

How can I get the target of a symlink in Perl 6?

You can create a symlink in Perl 6:

my $symlink-path = ...;
$target.symlink: $symlink-path;

Given just the symlink how can you get the target path?

$symlink-path.IO.????

I'm looking for the exact string that is the target, not any interpretation of that (such as .resolve).

Upvotes: 9

Views: 331

Answers (2)

wamba
wamba

Reputation: 4465

Method resolve works:

 my $target       = "../tmp/file".IO; 
 my $symlink-path = "files".IO;
 $target.symlink: $symlink-path;

 say $symlink-path.resolve;
 say $symlink-path.resolve(:completely) ~~ $target.resolve(:completely);

Upvotes: 3

Elizabeth Mattijsen
Elizabeth Mattijsen

Reputation: 26969

There is no equivalent in Perl 6 for that to my knowledge.

The closest thing to a solution, is to zef install P5readlink (https://modules.raku.org/dist/P5readlink) and use readlink like you would in Perl 5.

Upvotes: 5

Related Questions