While the space usage by Perl may astound you, when you start accounting for it, it turns out to be much more reasonable than you might think. For instance a basic scalar value has to have a pointer to a data structure, keep a reference count, and keep a bunch of flags to know what it currently is. That is 12 bytes of overhead for general behaviour related metadata, and we don't even have the data yet! Plus the things you are discounting, arrays and hashes and things, are all non-trivial data structures which involve lots of associated metadata, and then wasted space for internal buffering.

For more on this, you should take a look at Perl 5 Internals by Simon Cozens. And after that, dive into perlguts.

Perl isn't C. But the nice features don't come for free.


In reply to Re (tilly) 3: My scalars swell by tilly
in thread My scalars swell by kaatunut

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.