Problem of "Too many open files"

Y

Yash

Hi,
I am facing a problem with a Perl 5.6.1 program on HP-Ux 11i.
My program reads lines from a set of hundreds of files and based on a
particular field in every line, redistributes the lines to a new set
of files.
A new file is created using:
$fh{$timePartition} = IO::File->new("> $ENDIR/$timePartition.new") or
print LOGFILE "$!\n";


While running the program, I get an error at the above line saying
"Too many open files"

This is because I close the file descriptors after I am done with all
the input files.

Is there a way I can get around the problem from within Perl, by
increasing the value of some special variable?
If that is not possible, what system parameter should I increase to
avoid the problem?

Thanks
 
B

Ben Morrow

Quoth (e-mail address removed) (Yash):
Hi,
I am facing a problem with a Perl 5.6.1 program on HP-Ux 11i.
My program reads lines from a set of hundreds of files and based on a
particular field in every line, redistributes the lines to a new set
of files.
A new file is created using:
$fh{$timePartition} = IO::File->new("> $ENDIR/$timePartition.new") or
print LOGFILE "$!\n";

I wouldn't use IO::File... nowadays it has been superseded by lexical FHs:

open $fh{$timePartition}, '>', "$ENDIR/$timePartition.new"
or print LOGFILE "can't create '$ENDIR/$timePartition.new': $!\n";

I would also consider overriding CORE::GLOBAL::die to write to the logfile and
using that instead.
While running the program, I get an error at the above line saying
"Too many open files"

This is because I close the file descriptors after I am done with all
the input files.

Is there a way I can get around the problem from within Perl, by
increasing the value of some special variable?
No.

If that is not possible, what system parameter should I increase to
avoid the problem?

man ulimit

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top