Eporter::Easy gets rid of the drudgery of exporting symbols allowing you to
eliminate those bits of code that exists in every single module that uses
Exporter.
It also allows you to define tags in terms of other tags and you no longer
have to worry about filling in @EXPORT_OK.
So
require Exporter;
our @ISA = ('Exporter');
our @EXPORT = qw( open close );
becomes
use Exporter::Easy(EXPORT => [qw( open close ]);
and
use strict;
our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS, @VARS, @);
require Exporter;
our @ISA = ('Exporter');
@EXPORT = qw(getservbyname getservbyport getservent getserv);
@EXPORT_OK = qw( $s_name @s_aliases $s_port $s_proto );
%EXPORT_TAGS = (FIELDS => [ @EXPORT_OK, @EXPORT ] );
our ($s_name, @s_aliases, $s_port, $sx_proto);
$s_port = 8080;
becomes
use strict;
use Exporter::Easy(
EXPORT => [qw(getservbyname getservbyport getservent getserv)],
OK => [qw( $s_name @s_aliases $s_port $s_proto ]),
ALL => 'FIELDS',
);
$s_port = 8080;
and finally this becomes possible without lots of nasty arrays
use Exporter::Easy (
EXPORT => [qw( init :base )],
TAGS => [
base => [qw( open close )],
read => [qw( read sysread readline )],
write => [qw( print write writeline )],
misc => [qw( select flush )],
most => [qw( :base :read :write)],
no_misc => [qw( :all !:misc )],
],
OK => [qw( $some $other $stuff )],
ALL => 'all',
);
Exporter::Easiest lets you do leave out almost all of the punctuation, so
the above becomes
use Exporter::Easy q(
:base => open close
:read => read sysread readline
:write => print write writeline
:misc => select flush
:most => :base :read :write
:no_misc => :all !:misc
EXPORT => init :base
OK => $some $other $stuff
ALL => all
);
epxorting symbols can't get
any easier than this!
Written by Fergal Daly <fergal@esatclear.ie>