Um, no. Apparently you're not following me here.
You open all of the file handles (that's what they are called even if it's a pipe open) in a for loop. That loop executes before the while loop below it. That while loop contains the statement in which you attempt to close a file handle.
They are all opened before you close the first one, as I already told you. The one loop executes before the other, you see. Explicitly closing them will not keep them from all being opened at once unless you close them in the same loop where you open them. The while loop won't go back in time to close files for you. I know the Perl 5 team is good, but they haven't mastered time travel into the past just yet. I doubt you have the hardware necessary anyway.
The control flow in your program must follow the rules of control flow in the language you are using to implement the program.
You have to think of your program as executing over time. Making two system calls that relate to one another does not mean they happen in the same part of the program or near the same time. You must make the calls in the part of the program they are needed. The language is only doing what you ask, not guessing what you meant. I know Perl is designed to make small choices for you based on context when things are left implicit. It won't reorder your explicit control flow over multiple lines and multiple blocks, though.
If you want fewer files open at a time, you are going to have to close some of the files before you open others.
That the order of a set of actions influences their outcome isn't some crackpot conspiracy theory I'm trying to sell you in a survivalist pamphlet. That's just reality. If you go into your house after work tonight and open all the windows, then all of your windows will be open. If you then start closing them, you will still have had all of your windows open at some point. In order to have only a portion of the windows in your house open at a time, you must open some portion of them then close some portion of them before opening the rest. Your actions in the present can't change the past.
You came here asking for help. If you want to argue that you're smarter than I or more experienced, that's fine. Let's have that argument. I'm game for that, although this really isn't the venue. Don't argue with the advice I gave when you asked, though, until you try it or at least take the time to understand it. Arguing against the help you requested based on your own flawed understanding will not further anyone's understanding of the situation with your work. It may inform people about you in some ways, though. Confidence is good, but being cocksure about your understanding of some concept about which you just asked for help is just silly. Either you need help or you don't. Asking for help and dismissing unconsidered any help you get is not only rude but wasteful.
In reply to Re^2: old file descriptors not being cleaned up
by mr_mischief
in thread old file descriptors not being cleaned up
by wagnerc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |