The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ExportAbove - set sub or var names into @EXPORT* automatically

SYNOPSIS

  package SomeModule;
  use Exporter;
  use vars qw(@ISA);
  @ISA = qw(Exporter);
  
  $qux = ...;            # NOT export
  sub foo {...}          # NOT export
  no ExportAbove;
  
  @quux = (...);         # into @EXPORT
  sub bar {...}          # into @EXPORT
  use ExportAbove;
  
  %quuux = (...);        # into %EXPORT_TAGS and @EXPORT_OK
  sub baz {...}          # into %EXPORT_TAGS and @EXPORT_OK
  use ExportAbove qw(:Tag OK);
  
  $goo = ...;            # NOT export
  sub gle {...}          # NOT export
  # End of SomeModule

DESCRIPTION

ExportAbove sets your module's subroutine or variable (scalar, array or hash) names into @EXPORT, @EXPORT_OK or %EXPORT_TAGS automatically. You do not have to write '@EXPORT = qw(...);' and so on. You need only a 'use ExportAbove...;' line below the subroutine or variable definitions you want to export. You do not have to write same subroutine or variable names twice at '@EXPORT = qw(...);' and its definitions. If you want to change that names, you simply change only its definitions.

Set into @EXPORT

If you want to export some subroutines or variables in default, write as following below its definitions.

  use ExportAbove;

Set into @EXPORT_OK

If you want to export some subroutines or variables on demand, write as following below its definitions.

  use ExportAbove 'OK';

Set into %EXPORT_TAGS and @EXPORT

If you want to export some subroutines or variables in default or on demand by the tag name 'Tag', write as following below its definitions.

  use ExportAbove ':Tag';

Two or more tag names are available as following.

  use ExportAbove qw(:Foo :Bar);

Set into %EXPORT_TAGS and @EXPORT_OK

If you want to export some subroutines or variables not in default and on demand by the tag name 'Tag', write as following below its definitions.

  use ExportAbove qw(:Tag OK);

Two or more tag names are available.

Not export

If you do not want to export some subroutines or variables, write as following below its definitions.

  no ExportAbove;

Mixed uses

Mixed uses are available. See SYNOPSIS above.

Exceptional names

ExportAbove never set all capital names such as BEGIN, AUTOLOAD, @ISA,... into @EXPORT*.

Exporter required

ExportAbove does NOT export the names you specified. Exporter module does it. Please do NOT forget to use Exporter and set 'Exporter' into @ISA.

AUTHOR

nakajima@netstock.co.jp

SEE ALSO

Exporter