These "rules" do have exceptions sometimes. In my view, the point of "use @EXPORT_OK instead of @EXPORT" is to avoid cluttering up the user's namespace, and also to provide a bit more readability: use Config '%Config'; would tell the reader of the code exactly what is being exported, use Config; doesn't. I know some might disagree, but IMHO, some modules are so single-purpose that it's ok to export maybe one or two things by default, if their names won't lead to confusion (e.g. the name of the thing they export is traceable back to the name of the module). IMO, Config is such a single-purpose module, so it's ok to export %Config by default. Also, %Config is read-only, so "[the variables] can change under the hood, provoking horrible effects at-a-distance that are too hard to track and to fix" doesn't apply here either.

More exceptions might be: some modules exist for the explicit purpose of exporting a bunch of functions (e.g. to reduce boilerplate), and I also think it's sometimes acceptable to export certain variables on request (e.g. in a test script I might provide something like $DEBUG, where the fact that this is a global variable is not a problem).


In reply to Re: Why does Config.pm break the rules? by haukex
in thread Why does Config.pm break the rules? by Anonymous Monk

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.