I maintain the perl distribution Locale-Codes, and when I took over it, I inherited a number practices that I maintain for backward compatibility.

One of the things that the modules do is that they export a number of perl constants that can be used to specify exactly what code set you want to work with. So, when working with languages, the language module includes:

use Locale::Codes::Constants; our(@ISA,@EXPORT); @ISA = qw(Exporter); @EXPORT = qw(LOCALE_LANG_ALPHA_2);

I just added an object-oriented interface to the distribution, and I want to be able to specify the code set in the methods by using the constants (to be as similar to the traditional functions as possible).

I added the above lines to the OO module, and everything worked as desired, so I could just go ahead and leave it there, but it seems a bit wrong to export stuff in an OO module where typically everything is available via. a method.

Nothing is exported except for the constants, so is this generally considered an acceptable practice? Is there a better (i.e. more OO way) to make the constants available?


In reply to Exporter in an OO module? by SBECK

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.