export vs export_ok

Michael G Schwern schwern at pobox.com
Wed Nov 14 16:36:48 CST 2001


On Wed, Nov 14, 2001 at 10:12:37PM +0000, Scott McWhirter wrote:
> I would like to just be able to say
> use This::Thing;
> and then run &any anywhere within that script. I have it working with 
> @EXPORT but i know that cpan likes to use @EXPORT_OK but that requires a 
> qw(..) thing beside the use part. And i'd rather get away with using plain 
> "use This::Thing;"
> Any ideas would be of great help.

Stick with @EXPORT.

The somewhat overzealous "If you must export try to use @EXPORT_OK in
preference to @EXPORT" is somewhat overzealous.  If the whole point of
your module is to export one or two functions, use @EXPORT.

Rule of thumb: If every time you want to use the module you're going
to have to say:

    use Some::Module qw(this_func);

then you might as well just export this_func by default.


-- 

Michael G. Schwern   <schwern at pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa at perl.org>	     Kwalitee Is Job One
I know you get this a lot, but you're breathtaking, like a vision of
simplicity



More information about the Belfast-pm mailing list