Yes, import should run each time the module gets 'use'-d by a script/module/program/etc. 'use' is essentially a BEGIN block that first requires the other module, then runs its import class method. The file won't get re-loaded (ie. required) each time you use it, but the import method will get called each time.

You can test this by writing in your own import method and putting some debugging statements inside of it, eg. using caller to see who's calling import.

But, in a sort of unrelated to your question thing, you say that you're going to be using these functions in almost every one of your scripts and modules. In that case, might I suggest thinking about an OO approach? It may not fit your model, in which case go with the exported functions; but if it does fit, you'll be saving on a lot of exported symbol table entries, if you're really going to export functions to each of your namespaces. Just a thought, anyway; I'm not saying "go OO", just to think about it if you haven't already.


In reply to Re: exporter and multiple namespaces by btrott
in thread exporter and multiple namespaces by AidanLee

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.