in reply to How do I export methods and constants from a package module?
The module you want to look at is Exporter. In general, if you create your modules using 'h2xs -X', all of this will be set up for you. You can export constants just like functions (because really, thats all they are)
require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not expo +rt # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use My::Module ':all'; # If you do not need this, moving things directly into @EXPORT or @EXP +ORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I export methods and constants from a package module?
by tadman (Prior) on Apr 17, 2002 at 23:08 UTC | |
by ehdonhon (Curate) on Apr 17, 2002 at 23:16 UTC | |
by tadman (Prior) on Apr 17, 2002 at 23:32 UTC | |
by ferrency (Deacon) on Apr 18, 2002 at 16:54 UTC |