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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.