package MyExporter; use Exporter (); BEGIN { our @ISA = 'Exporter'; } sub import { our @EXPORT_OK; our @EXPORT_TAGS; #my $pkg = \%::; #$pkg = $pkg->{$_} foreach ((caller().'::') =~ /\G(.*::)/g); my $pkg = caller() . '::'; { no strict 'refs'; $pkg = *$pkg; } local *EXPORT_OK = $pkg->{'EXPORT_OK'}; local *EXPORT_TAGS = $pkg->{'EXPORT_TAGS'}; { # Expand tag names into referenced name sets my %seen; $EXPORT_TAGS{all} = [ grep { !$seen{$_}++ } map { m/^:(.*)$/ ? @{$EXPORT_TAGS{$1}} : $_ } @{$EXPORT_TAGS{all}} ]; } { # Add tag set names not already listed into @EXPORT_OK my %seen; $seen{$_}++ foreach @EXPORT_OK; push @EXPORT_OK, grep { !$seen{$_}++ } @{$EXPORT_TAGS{$_}} foreach keys %EXPORT_TAGS; } &Exporter::import; }