kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Revered MOnks,

Does perl have any limitation on number of files it can open. Or does it have any confiurable parameter to handle the number of files it can open. I face some issue in my current project.

Please throw some light here


-Prasanna.K

Replies are listed 'Best First'.
Re: number of open files Perl can handle
by BrowserUk (Patriarch) on Nov 11, 2009 at 09:22 UTC

    You can find out your systems (OS) currently configured limit easily:

    >perl -le"my @a; open $a[ $_ ], '>', qq[file$_] or die qq[$!:$_] for 1 + .. 10e3" Too many open files : 2046 at -e line 1.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: number of open files Perl can handle
by ikegami (Patriarch) on Nov 11, 2009 at 06:00 UTC
    I don't see why Perl would have a limit. OSes, on the other hand, tend to have limits.
Re: number of open files Perl can handle
by cdarke (Prior) on Nov 11, 2009 at 08:48 UTC
    There are a number of limits, some depend on the operating system. The C runtime library might have limits, the user name you run under might have limits, and there can be global limits set. If you let us know the exact error message you are getting ($! and maybe $^E), and the operating system, then we might be able to help further.
Re: number of open files Perl can handle
by Bloodnok (Vicar) on Nov 11, 2009 at 09:24 UTC
    As ikegami has already alluded to, perl doesn't impose a limit on the max. number of open files - this is done by the underlying OS e.g. /proc/sys/fs/file-max on Linux, /etc/system on Solaris etc. etc.

    Your OS docs &/or Google are your friends for further details...

    A user level that continues to overstate my experience :-))
Re: number of open files Perl can handle
by matze77 (Friar) on Nov 11, 2009 at 06:44 UTC

    As stated by ikegami Perl is not limitating. Your "ressources" may get a limit, first the os-limitations, then maybe the "available" memory of your systems, Perl may use up all your memory e.g. ...

    hth MH
Re: number of open files Perl can handle
by spx2 (Deacon) on Nov 11, 2009 at 14:10 UTC

    I've seen this question many times, and in practice I didn't need to keep open at the same time so many files.

    I am honestly interested in what situation you would need this because I cannot think of one.