IMHO, Perl has enough syntax.
Exporting functions adds to what looks like core syntax even though it's not. Forcing a user of your module to explicitly import something, to access it through the package namespace, or to create and object with which to interact all give a better clue as to where different variables and functions/modules come from.
Exporting variables by default isn't any better. Your user is often writing the type of application for which you designed your module. There's often a lot of similar ideas for how to name variables when you and another person are working on the same problem. So please, don't give your user variables he's going to accidentally override.
So I'd say that it is best to export nothing by default. Exporting upon request is okay. Object instantiation is okay. Exporting nothing and requiring the namespace to be specified is okay.
Don't give me main::some_func() and especially not $main::some_var unless I ask for them. I don't want the potential conflicts, and I don't want to look back six months from now and have to search through my code and eight modules to figure out where $foo got set.
The subroutines might not be so bad for an experienced Perl programmer because they've had time to assimilate what should be core syntax and what doesn't look familiar. A new Perl programmer, though, is likely already overwhelmed with all that's in
perlfunc and will only get confused further by what's provided by CORE and what's provided by your module looking alike. Variables are always an issue, though, so that's even worse.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.