It's a shared opinion that Perl was born to be useful, rather than restrictive. That's why there are (almost) no limits (computationally speaking) in terms of what a Perl program can do.

Beware, this does not mean you're free to do whatever you want. You have enough rope to hung yourself, if you want, but you can also use strict or features not even conceivable in other languages like taint checks.

So basically it is like you said: empirical limits are almost certainly dictated by the operating system (e.g. maximum memory usage -- but you can always compile Perl so thatit reserves some space for emergencies), and then an experienced programmers knows how to scope and limit their code so that it can be reliable, tested, documented and useful. For example, limiting, if not eliminatig, global variables is considered very good practice, even if the language itself allows you to do that. So, you are supposed to know when it's a good thing and when it's more trouble than it's worth.

So, for operating system limits in a UNIX context you may want to check out getrlimit(2), setrlimit(2), and sysconf(3). There's not much you can do about these limits, if you're not root. Especially a maximum number of open file descriptors which is not too high might cause troubles in Perl, which is so useful for dealing with files and network connections (they count as open file descriptors). Or you can be creative and overcome a max memory usage limit forking your process and distributing the computation, but then again you may incur into a maximum number of processes limit :-)

Another annoying problem may be a quota limit, that forces you to use no more than X Mb on filesystems. Being so good at slurping and processing files, this can affect you if you handle e.g. Web server logs.

The Posix module defines some constants that can help you in finding out for example the biggest integer that the architecture can save in a C int variable and so on. It also allow you to import (at least in 5.6.1) the sysconf function, so that you know what limits are you subjected to, and the workaround can be (if needed) tailored to your specific program, maybe using your creativity :-)

I don't know much about other Perl internal limits. Surely someone more experienced (Him in person?) knows much more about them. I can think of maximum number of identifiers in symbol table, maxim length of identifiers and so on, but I would be very suprised in bumping into those limits, if they exist at all.

-- TMTOWTDI


In reply to Re: Limits in Perl by trantor
in thread Limits in Perl by Fool on the Hill

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.