summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Granum <exodist7@gmail.com>2016-08-20 13:57:57 -0700
committerChad Granum <exodist7@gmail.com>2016-08-20 13:59:09 -0700
commit7aff74b4ae78cf1b83c93eb84f56dbc4803d1539 (patch)
treee21c18c5beb9ebcd9104d1116f59110cf8a37191
parent51aa385ce06d70f5724e2f1aaedca567beb0e0c6 (diff)
Extract _build_menu
-rw-r--r--lib/Importer.pm70
1 files changed, 38 insertions, 32 deletions
diff --git a/lib/Importer.pm b/lib/Importer.pm
index 39e9407..807303c 100644
--- a/lib/Importer.pm
+++ b/lib/Importer.pm
@@ -302,50 +302,57 @@ sub reload_menu {
my $from = $self->from;
- my (
- $export,
- $export_ok,
- $export_tags,
- $export_fail,
- $generate,
- $export_gen,
- $export_anon,
- $export_magic,
- $new_style
- );
-
if (my $menu_sub = *{"$from\::IMPORTER_MENU"}{CODE}) {
# Hook, other exporter modules can define this method to be compatible with
# Importer.pm
- $new_style = 1;
-
my %got = $from->$menu_sub($into, $self->get_caller);
- $export = $got{export} || [];
- $export_ok = $got{export_ok} || [];
- $export_tags = $got{export_tags} || {};
- $export_fail = $got{export_fail} || [];
- $export_anon = $got{export_anon} || {};
- $export_magic = $got{export_magic} || {};
+ $got{new_style} = 1;
- $export_gen = $got{export_gen};
- $generate = $got{generate};
+ $got{export} ||= [];
+ $got{export_ok} ||= [];
+ $got{export_tags} ||= {};
+ $got{export_fail} ||= [];
+ $got{export_anon} ||= {};
+ $got{export_magic} ||= {};
$self->croak("'$from' provides both 'generate' and 'export_gen' in its IMPORTER_MENU (They are exclusive, module must pick 1)")
- if $export_gen && $generate;
+ if $got{export_gen} && $got{generate};
- $export_gen ||= {};
+ $got{export_gen} ||= {};
+
+ return $self->_build_menu($into => \%got);
}
else {
- $export = \@{"$from\::EXPORT"};
- $export_ok = \@{"$from\::EXPORT_OK"};
- $export_tags = \%{"$from\::EXPORT_TAGS"};
- $export_fail = \@{"$from\::EXPORT_FAIL"};
- $export_gen = \%{"$from\::EXPORT_GEN"};
- $export_anon = \%{"$from\::EXPORT_ANON"};
- $export_magic = \%{"$from\::EXPORT_MAGIC"};
+ my %got;
+ $got{export} = \@{"$from\::EXPORT"};
+ $got{export_ok} = \@{"$from\::EXPORT_OK"};
+ $got{export_tags} = \%{"$from\::EXPORT_TAGS"};
+ $got{export_fail} = \@{"$from\::EXPORT_FAIL"};
+ $got{export_gen} = \%{"$from\::EXPORT_GEN"};
+ $got{export_anon} = \%{"$from\::EXPORT_ANON"};
+ $got{export_magic} = \%{"$from\::EXPORT_MAGIC"};
+
+ return $self->_build_menu($into => \%got);
}
+}
+sub _build_menu {
+ my $self = shift;
+ my ($into, $got) = @_;
+
+ my $from = $self->from;
+
+ my $export = $got->{export} || [];
+ my $export_ok = $got->{export_ok} || [];
+ my $export_tags = $got->{export_tags} || {};
+ my $export_fail = $got->{export_fail} || [];
+ my $export_anon = $got->{export_anon} || {};
+ my $export_magic = $got->{export_magic} || {};
+ my $export_gen = $got->{export_gen} || {};
+ my $new_style = $got->{new_style} || 0;
+
+ my $generate = $got->{generate};
$generate ||= sub {
my $symbol = shift;
my ($sig, $name) = ($symbol =~ m/^(\W?)(.*)$/);
@@ -501,7 +508,6 @@ sub parse_args {
my %seen;
@list = grep !$seen{$_}++, map {m/^\W/ ? $_ : "\&$_" } @list;
-
if ($exc) {
$exclude{$_} = 1 for @list;
}