perl 5.8.8 on a recent fedora:

I was attempting to see if the same file existed in two directories. So I set up:

my $d1 = 'mydir/filename';
my $d2 = 'myotherdir/filename';

print "both places" if -e $d1 && -e $d2;

............

Both directories already exist and I have full access to each one and own each one. 

Then I placed the file in the dir in d1, and NOT in the dir in d2, and ran the script. It printed "both places"... 
*TILT*


So I pulled it into the debugger and broke at *if*. Then did

dbg> x -e $d1
0 1


dbg> x -e $d2
0 undef


dbg> x $d2
0 '/myotherdir/filename'

then I cut /myotherdir/ form the result and dropped to linux and ls'ed it and there it was, no issues.

HOW would -e return undef on an existing dir to which I have 777 access? to make matters worse, I then tried

if ( -e $d1 && defined -e $d2 && $d2 )

and it was TRUE! I checked inside the loop and -e $d2 was undef, yet this statement returned true.

.......
I ALSO went to the docs for -e and I didn't see ANY conditions described in which it would EVER return undef (although I might expect it to, if the dir structure was improper, etc so perhaps the docs are incomplete). But in my case, my directory is correct.
..
Fridays are sposed to NOT go this way.. ack!


In reply to -e stransgeosities by misterperl

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.