misterperl has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: -e stransgeosities
by Corion (Patriarch) on Apr 20, 2012 at 15:07 UTC | |
|
Re: -e stransgeosities
by pvaldes (Chaplain) on Apr 20, 2012 at 15:42 UTC | |
by misterperl (Friar) on Apr 23, 2012 at 13:44 UTC | |
by Corion (Patriarch) on Apr 23, 2012 at 13:49 UTC | |
by Jenda (Abbot) on Apr 23, 2012 at 23:33 UTC |