Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
1. I open an existing file. Result: OK
2. I try to open or test the existance of a non-existing file with "-e"
3. I open an existing file. Result: ERROR
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.
The test program:
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"; }
test.out is an existing file, tt1 is not. The output is:
1. [OK] 3. [ERROR]
If I comment out the middle part, the if (-e "tt1") { ... and just simply open & read & close the file twice, I get:
1. [OK] 2. [OK]
This is more, than annoying and more than weird. Could you please suggest any workarounds?

In reply to unable to open existing file after trying to open a non-existing one by monk_of_gaia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-16 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found