I am having some trouble in file testing. Please see my sample code first:
I don't understand why '-w $f' returns TRUE?
Thanks for the help.
Code:
[Linux|bash] 133 => cat /etc/issue
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
Kernel \r on an \m
[Linux|bash] 134 => pwd
/test
[Linux|bash] 135 => ls -l
total 16
-r-------- 1 root root 28 Apr 28 18:23 log.txt
-rwxr-xr-x 1 root root 140 Apr 28 18:21 tt.pl*
[Linux|bash] 136 => cat tt.pl
#! /usr/local/bin/perl
my $f = "log.txt";
if(-w $f) {
print "File '$f' is writable.\n";
}
else {
print "File '$f' is NOT writable.\n";
}
[Linux|bash] 137 => ./tt.pl
File 'log.txt' is writable.
I don't understand why '-w $f' returns TRUE?
Thanks for the help.