I've read that when working on programs where memory usage is important, it is best to avoid importing symbols from other packages
Importing stuff from modules isn't that expensive, and avoiding importing it won't save much. You see, the subs etc in the module, already exist in memory, as soon as the module is loaded. Even if you never call them, or even don't import them.

All that import does, is add a new name for the same sub in the symbol table for the current package. There is no recompilation, not even a copy of the sub body, for the new import!

n.b. The symbol table, or stash, is nothing but a plain hash containing globs, which are just binary structures with refs to various types of data sharing the same name — for example a reference to a sub body in the slot for the code ref.

So... I think you must misremember what you read. It is recommended not to import stuff from modules that you don't use, but not to save on memory, but in order to not to clutter the symbol table with useless stuff. Because every imported name restricts the choice you have for your own names of subs — thus: to prevent name clashes.


In reply to Re: Idea for new module/pragma by bart
in thread Idea for new module/pragma by zealot

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.