Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^8: true from (-e "") on Windoze (" is an illegal filename character

by ikegami (Pope)
on Sep 17, 2012 at 23:06 UTC ( #994147=note: print w/ replies, xml ) Need Help??


in reply to Re^7: true from (-e "") on Windoze (" is an illegal filename character
in thread true from (-e "") on Windoze

The system call that underlies dir is the same system call that underlies -e, thus similar behaviour is entirely appropriate.

The behaviour of Perl functions is not dictated by what some system call does.

Making Perl work differently would be as asinine as truncating 32-bit return codes to 8-bits.

I would like Perl to stop working differently than documented. Neither that desire nor the documented behaviour is asinine.


Comment on Re^8: true from (-e "") on Windoze (" is an illegal filename character
Re^9: true from (-e "") on Windoze (" is an illegal filename character
by BrowserUk (Pope) on Sep 18, 2012 at 02:32 UTC
    I would like Perl to stop working differently than documented.

    Don't tell me, let me guess.

    On the basis of that piece of self-asserting, broken and twisted logic, you are going to change perfectly valid and reasonable platform specific behaviour on windows, to fit the undocumented and platform specific behaviour exhibited on *nix.

    Nowhere is the behaviour of -e '""' documented. Two different behaviours are observable, that fit with the local patterns and conventions of those platforms. And you are going to break a useful and logical feature of one platform to make it fit the non-useful and illogical behavour on the other. Rather than just document the platform difference.

    Now, THAT is the very definition of asininity!


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      No, I want to change it because the current behaviour is not reasonable. I need a function that checks if file exists, -e is suppose to be that function, but you're telling me it's not.
        . I need a function that checks if file exists

        Then don't ask it: "do any files exist".


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        div class=
        I need a function that checks if file exists

        Seems to me that (on Windows) we can be assured that the specified $file exists if any one of the following three conditions returns true:
        -T $file || -B $file defined -T $file defined -B $file
        I was also wondering about using -f instead of -e. Are there any files on Windows that will report false for -f ? (If so, then we can't use -f as a test for existence.)

        Someone really ought to file a bug report about this because the perldoc -f -X documentation does *not* match the behaviour wrt '-e'.
        That documentation implies that -e '""' will return true only if a file named "" exists.
        Either the behaviour ought to change to fit the documentation, or the documentation be amended to fit the behaviour.
        The documentation also implies that defined -f '""' will return false (but it doesn't).
        Here's what I ran as a check:
        #!perl -l use warnings; print "-f:"; -f '""' ? print "Returned True (unwanted behaviour)\n" : print "Returned False (wanted behaviour)\n"; print "defined -f:"; defined -f '""' ? print "Returned True (unwanted behaviour)\n" : print "Returned False (wanted behaviour)\n"; print "-T || -B:"; (-T '""' || -B '""') ? print "Returned True (unwanted behaviour)\n" : print "Returned False (wanted behaviour)\n"; print "defined -T:"; defined -T '""' ? print "Returned True (unwanted behaviour)\n" : print "Returned False (wanted behaviour)\n"; print "defined -B:"; defined -B '""' ? print "Returned True (unwanted behaviour)\n" : print "Returned False (wanted behaviour)\n";
        And here's the output I got:
        -f: Returned False (wanted behaviour) defined -f: Returned True (unwanted behaviour) -T || -B: Returned False (wanted behaviour) defined -T: Returned False (wanted behaviour) defined -B: Returned False (wanted behaviour)
        I don't mind filing a bug report about this, but I'll wait for comments about that first (in case I've overlooked something).

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-09-02 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (19 votes), past polls