In "Programming Perl" -w
file-test operator described as:
–w File is writable by effective UID/GID.
I have two files:
-rwsrwxrwx 1 testuser testuser 226 Jul 20 20:31 script.pl
-rw-rw-r-- 1 testuser testuser 34 Jul 14 17:24 file.txt
suid
is set on script.pl
, so when I run it as user caligula, effective UID/GID should be the testuser's one. script.pl
is:
#!/usr/bin/perl
use v5.14;
if (-w 'file.txt') {
say "true";
}
else {
say "false";
}
But when I run it caligula@ubuntu-host:~$ ./script.pl
the output is always false
. Why does that happen, may be I didn't understand the correct usage of that operator?
My appreciation.