But what if my program already has a get_string() function or an %N hash, and I add this module after the fact?
Well, so what? You _do_ know the working of Perl, don't you? Then you _do_ know that if you do:
use Module ();
the import() routine isn't called, and nothing will be exported. In which case, you can still use the function by calling it like:
Module::get_string ()
But a name clash is an exceptional case - normally you don't have a name clash (I've been programming Perl for over 6 years now, I cannot recall ever having had a name clash problem), and you can just use the short get_string. But with a class method, you have to use Module -> sub, even if it's not necessary.
The OO isn't really pointless. It's happening either way-- exporting symbols without being asked to do so is just a sneaky way of concealing it is all.
Exporting symbols without being asked is only a sneaky way if there isn't an easy way to avoid it. All you need to do is ask to _not_ import anything. That takes a whopping two characters. A module author using Exporter gives the programmer a choice - a module author using OO to avoid name clashes doesn't. I know who acts Perlish, and it ain't the latter programmer.

As for the %N of Lingua::EN::Numbers::Easy, let me quote from the manual:

       By default, "Lingua::EN::Numbers::Easy" exports a hash
       "%N" to the importing package. Also, by default, "Lin-
       gua::EN::Numbers::Easy" uses the British mode of "Lin-
       gua::EN::Numbers". Both defaults can be changed by
       optional arguments to the "use Lingua::EN::Numbers::Easy;"
       statement.
   
       The first argument determines the parsing mode of "Lin-
       gua::EN::Numbers".  Currently, "Lingua::EN::Numbers" sup-
       ports British and American.  The second argument deter-
       mines the name of the hash in the importing package.

           use Lingua::EN::Numbers::Easy qw /American %nums/;
    
       would use American parsing mode, and "%nums" as the tied
       hash.
If %N gives you a name clash, just use any other suitable name. OO isn't the only way of solving name clash problems!

Abigail


In reply to Re: Use modules or roll your own? by Abigail-II
in thread Use modules or roll your own? by kvale

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.