I think I have stumbled onto a bug. I'd like one of the gurus (Jeff, druiex,
Jenda or any perlguy.com) to confirm that my test is correct or if I missed
something in docs.
using Perl 5.6.1 on a Solaris sparc.

#perl
use strict;
use warnings;

my $wofile = "noread";  # text file with no read permissions
my $file = "canread";   # text file with read perms

if( -T $file ){  # will be true
        print "exists\n" if -e _;  # will print
        } else {
        print "doesn't exist\n" unless -e _;
        }

## here's the possible bug
if( -T $wofile ){  # will be false (you need read to determine if text file)
        print "exists\n" if -e _;
        } else {
        print "doesn't exist\n" unless -e _;  # will print BUT SHOULDN'T
        }

__END__


According to perldoc perlfunc about file tests:
             If any of the file tests (or either the "stat" or
             "lstat" operators) are given the special filehandle
             consisting of a solitary underline, then the stat
             structure of the previous file test (or stat
             operator) is used, saving a system call.



Nikola Janceski

Go with the flow, don't get caught in the current.
-- Nicky J. from da' Bronx


----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to