BrowserUk wrote:
In essence, what you are passing is not a filename (or a filehandle). If you remove the '<' and '>>', you'll then get the results you are hoping for.
I do understand what you are saying here. However, I'm not trying to have the file test succeed based on open's specical semantics, but rather I'm trying to _detect_ whether somebody else is trying to use open's 2 arg semantics with my module. I fully expect the file test to fail if somebody tries to use, for example, '>>testfile.log' as an argument to my module's 'new()' or 'open()' methods.
(Does that make sense?! :-) )
The use of '< file' in the two ar form of open is unique (and only applicable) to that call (open)...
This was my point! :-) As far as I knew, the only place where one was allowed to use the magic semantics of the first argument to 'open', is in the first argument to open!
However, for some weird reason, on Windows, a file test on '<testfile.log' (or '<<testfile.log', or even '<<<<<<<<testfile.log') returns true. However, I have just done some more digging, and I think it is a problem with Windows, rather than Perl.
C:\>perl -e "my $f=qq(<testfile.log); print ref($f); if (-f $f) { prin +t qq(AS thinks this is a file\n); }" AS thinks this is a file C:\>dir "<testfile.log" Volume in drive C has no label. Volume Serial Number is D0C3-B79D Directory of C:\ 19/09/2003 15:03 0 testfile.log 1 File(s) 0 bytes 0 Dir(s) 1,764,376,576 bytes free C:\>dir "<<testfile.log" Volume in drive C has no label. Volume Serial Number is D0C3-B79D Directory of C:\ 19/09/2003 15:03 0 testfile.log 1 File(s) 0 bytes 0 Dir(s) 1,764,376,576 bytes free C:\>dir "<<<<<<<<<testfile.log" Volume in drive C has no label. Volume Serial Number is D0C3-B79D Directory of C:\ 19/09/2003 15:03 0 testfile.log 1 File(s) 0 bytes 0 Dir(s) 1,764,376,576 bytes free
Looks like this may just be another Microsoft "feature". How helpful of them! ;-)
Cheers,
-- Dave :-)
$q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print
In reply to Re: Re: Unexpected file test (-f) result on Windows
by DaveH
in thread Unexpected file test (-f) result on Windows
by DaveH
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |