Ravi, Please don't top post.
On 12/2/06, Ravi Malghan <[EMAIL PROTECTED]> wrote:
Hi all: thanks for the responses. I should have done this in the beginning. I checked the status open returns. I try to open 388 files, but it returned true(1) only 249 times (for the first 249 opens). So I guess thats the limit.
Don't count on it. The limit (as reported by ulimit) is 256. You can open 249 because you already have 6 files/file descriptors open. That may not always be the case. Modules, for instance, may open files, descriptors, or pipes that you aren't aware of.
Also to make sure I am doing the right way, the following is how I am opening the files $AgentFH{$id} = *$name; open($AgentFH{$id}, ">>$filename");
If you're using a recent version of Perl, open will accept a scalar as an indirect filehandle: open($name, ">>", $filename); Then you can take a reference to the handle and store it in your hash. That's probably better than globbing first, because you won't need too do the assignment if the open fails. Also, open accepts an undefined scalar as a filehandle ref, so your code isn't doing quite what you think it is. It's being parsed as something equivalent to open(ref($AgentFH{$id}) ...); Which appears to work because $AgentFH{$id} will always be unique, but it isn't what you think it is, and may behave unexpectedly. finally, always check the return value of open, and behave appropritely if it fails: open($name, ">>", $filename) or die "$!\n"; # or open($name, ">>", $filename) or your_error_sub($!); # or something like that
I am speaking to the system admin if he can bump up the limit to 1024. Any other thoughts?
Yes. See Tom's suggestion about the FileCache CPAN module. you might also be able to fool the system by forking a number of child processes to handle the IO. Each one could handle, say, 100 files. FileChache is simpler, though. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!