monk_of_gaia has asked for the wisdom of the Perl Monks concerning the following question:
test.out is an existing file, tt1 is not. The output is: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"; }
If I comment out the middle part, the if (-e "tt1") { ... and just simply open & read & close the file twice, I get:1. [OK] 3. [ERROR]
This is more, than annoying and more than weird. Could you please suggest any workarounds?1. [OK] 2. [OK]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unable to open existing file after trying to open a non-existing one
by liz (Monsignor) on Sep 23, 2003 at 15:40 UTC | |
by monk_of_gaia (Initiate) on Sep 23, 2003 at 16:00 UTC | |
|
Re: unable to open existing file after trying to open a non-existing one
by pzbagel (Chaplain) on Sep 23, 2003 at 15:48 UTC | |
|
Re: unable to open existing file after trying to open a non-existing one
by asarih (Hermit) on Sep 23, 2003 at 15:42 UTC |