J
Justin
Hi,
I've noticed that the -r operator returns undef if used on a file in an
unreadable directory (where undef indicates the file is missing) - I'd
like -r to return false (unreadable) in such a case.
I'm comparing our back-up file-list to the file-system. I need to know
if a file exists or if I just can't read it.
ls returns 'Permission Denied' which is what I'd like -r to return.
Any ideas?
Cheers,
Justin
Here's an example of what I mean:
[/tmp] mkdir Test
[/tmp] touch Test/testfile
[/tmp] ls -l Test
total 0
-rw-rw-r-- 1 ja 0 Oct 30 12:58 testfile
[/tmp] chmod 000 Test
[/tmp] perl -e 'print "Not Exist\n" unless defined (-r "Test/testfile")'
Not Exist
[/tmp] ls Test/testfile
ls: Test/testfile: Permission denied
[/tmp] perl -e 'print "Not Exist\n" unless defined (-r "Test")'
[/tmp]
I've noticed that the -r operator returns undef if used on a file in an
unreadable directory (where undef indicates the file is missing) - I'd
like -r to return false (unreadable) in such a case.
I'm comparing our back-up file-list to the file-system. I need to know
if a file exists or if I just can't read it.
ls returns 'Permission Denied' which is what I'd like -r to return.
Any ideas?
Cheers,
Justin
Here's an example of what I mean:
[/tmp] mkdir Test
[/tmp] touch Test/testfile
[/tmp] ls -l Test
total 0
-rw-rw-r-- 1 ja 0 Oct 30 12:58 testfile
[/tmp] chmod 000 Test
[/tmp] perl -e 'print "Not Exist\n" unless defined (-r "Test/testfile")'
Not Exist
[/tmp] ls Test/testfile
ls: Test/testfile: Permission denied
[/tmp] perl -e 'print "Not Exist\n" unless defined (-r "Test")'
[/tmp]