perlquestion
monk_of_gaia
1. I open an existing file. Result: OK<br>
2. I try to open or test the existance of a non-existing file with "-e"<br>
3. I open an existing file. Result: ERROR<br>
I tried it with Perl v5.003_07 for Win32 Build 316, Perl v5.004_02 Win32 and 5.005_03 built for MSWin32-x86-object build 518. I have BMC Patrol on this Win2k machine, and these Perls comes with BMC Patrol. It is not possible at this moment to upgrade Perl on this machine.<br>
The test program:
<code>
open TT1, "<test.out";
if ($! == 0) {
print "1. [OK]\n";
@x = <TT1>;
close TT1;
} else {
print "[ERROR]\n";
}
if (-e "tt1") {
open TT2, "<tt1";
if ($! == 0) {
print "2. [OK]\n";
close TT2;
} else {
print "2. [ERROR]\n";
}
}
open TT1, "<test.out";
if ($! == 0) {
print "3. [OK]\n";
@x = <TT1>;
close TT1;
} else {
print "3. [ERROR]\n";
}
</code>
test.out is an existing file, tt1 is not.
The output is:
<code>
1. [OK]
3. [ERROR]
</code>
If I comment out the middle part, the if (-e "tt1") { ... and just simply open & read & close the file twice, I get:
<code>
1. [OK]
2. [OK]
</code>
This is more, than annoying and more than weird. Could you please suggest any workarounds?