Perl 5.6 (?) introduced the new 'our' operator,
which I have taken a liking to, as, once you understand
the subtle differences between it and 'my' and 'local',
it can improve readability and flexibility.
Is there anything wrong with declaring a typical
package/module as follows:
package Xyz;
use strict;
use Exporter;
our (@EXPORT) = qw [
FunctionAlpha
FunctionBravo
FunctionCharlie
$calarDelta
];
our (@EXPORT_OK) = qw [
FunctionEcho
$calarFoxtrot
];
our (@ISA) = qw [ Exporter ];
tilly's
recent post, which was about the
perils of
BEGIN blocks, even though I recall
that a while back they were 'the way to go' for export
declarations, but this could have been an early Perl5 thing.
There are some curious things that some modules do to
get things to run smoothly while under the influence of
'strict' and '-w', such as:
- Put @EXPORT/@ISA declarations inside of a BEGIN block
- 'use vars' for @EXPORT,@ISA
- Delay the insertion of 'use strict' to after the preamble
- Disable 'strict' temporarily to allow loading.
All of these seem a little excessive for something that should
be pretty simple.
Once I tried to write a wrapper filter that would auto-export
any functions tagged 'exportable' but this was a
war I could not win.
Maybe in Perl 6.
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.