On 2019-09-07 1:25 p.m., Jorge Almeida wrote:
Sorry about the title, it's the best I can do...

#!/usr/bin/perl
use strict;
use warnings;
my $num=12;
my $target=pack('n', $num);
symlink($target, "foo") || die $!;

It dies with "No such file or directory"
No symlink is created. What I want is a symlink named "foo" pointing
to a 2-byte string. Yes, it would be a broken symlink. (Yes, this is
how I want it).

Symlink() can create broken links, the problem is the target. What to
do? (And why doesn't it work?)


$ perl -le'
use warnings;
use strict;
use Data::Dumper;
$Data::Dumper::Useqq = 1;

my $num = 12;
my $target = pack "n", $num;
print Dumper $target;
'
$VAR1 = "\0\f";


On Unix/Linux a character in a file name can be any character except a slash '/' character because that is used to separate path elements, or a null "\0" character because that is what the C language uses to signify the end of a string.

So your Perl string "\0\f" is read by C as a zero length string.


John

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to