Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: -e " " returns true

by crazyinsomniac (Prior)
on Jul 05, 2004 at 16:00 UTC ( [id://371917]=note: print w/replies, xml ) Need Help??


in reply to Re: -e " " returns true
in thread -e " " returns true

ActivePerl Build 809
v5.8.3 built for MSWin32-x86-multi-thread
#!/usr/bin/perl use strict; use warnings; my @files = (' ', ' . . ', ' .. ', ' ', ' . '); foreach (@files) { print "[$_] - ", -e $_ ? "yes\n" : "no\n"; } __END__ [ ] - yes [ . . ] - yes [ .. ] - yes [ ] - yes [ . ] - yes

Replies are listed 'Best First'.
Re^3: -e " " returns true
by PerlingTheUK (Hermit) on Jul 05, 2004 at 16:12 UTC
    This is one of the times I really wish I was still on Linux.
    Thanks for trying as well and all those fast replies.

    Hans
      Hey PerlingTheUK,

      Here's a quick fix for you until you get around this problem. It produces correct results for those dotty filenames both under Windows XP (5.6.1 active perl) and Linux (RedHat 9, 5.6.1 as well).
      my $f = ". ."; my $result = minuse ($f); print "[$result]\n"; sub minuse { -f $_[0] || &minusd} sub minusd {local *D; opendir (D, shift) && (close (D) || 1)}
        Thank you very much, that works fine. I have installed Build 510 in the meantime and tested -e using that release. All dotty files exist in that build as well, but anyway, this fix is fine for now.

        Hans

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-19 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found