From: Leon Timmermans Date: Mon, 21 Jan 2013 14:49:14 +0000 (+0100) Subject: Cleanup X-Git-Tag: v0.001007~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea84f762b58f822d6a11cf1acc8f85501ddd2029;p=p5sagit%2FSub-Exporter-Progressive.git Cleanup --- diff --git a/lib/Sub/Exporter/Progressive.pm b/lib/Sub/Exporter/Progressive.pm index f4bed06..4db4cf1 100644 --- a/lib/Sub/Exporter/Progressive.pm +++ b/lib/Sub/Exporter/Progressive.pm @@ -11,11 +11,11 @@ use List::Util 'first'; sub import { my ($self, @args) = @_; - my $inner_target = caller(0); + my $inner_target = caller; my $export_data = sub_export_options($inner_target, @args); my $full_exporter; - no strict; + no strict 'refs'; @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}}; @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}}; %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}}; @@ -26,8 +26,7 @@ sub import { if (first { ref || !m/ \A [:-]? \w+ \z /xm } @args) { croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed' unless eval { require Sub::Exporter }; - $full_exporter ||= - Sub::Exporter::build_exporter($export_data->{original}); + $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original}); goto $full_exporter; } else { @@ -37,6 +36,7 @@ sub import { goto \&Exporter::import; } }; + return; } my $too_complicated = <<'DEATH'; @@ -66,7 +66,7 @@ sub sub_export_options { } elsif ($opt eq 'groups') { %tags = %{$options{groups}}; for my $tagset (values %tags) { - croak $too_complicated if first { /^-(?!all\b)/ || ref } @{$tagset}; + croak $too_complicated if first { / \A - (?! all \b ) /x || ref } @{$tagset}; } @defaults = @{$tags{default} || [] }; } else { @@ -75,8 +75,9 @@ sub sub_export_options { } @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags; $tags{all} ||= [ @exports ]; - my @errors = grep { my $default = $_; !grep { $default eq $_ } @exports } @defaults; - die join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; + my %exports = map { $_ => 1 } @exports; + my @errors = grep { not $exports{$_} } @defaults; + croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; } return {