return 1;
}
-my %exports = (
+my %default_exports = (
load_or_skip => \&load_or_skip,
load_or_skip_all => \&load_or_skip_all,
run_perl => \&run_perl,
skip_all => \&skip_all,
);
+my %features = ();
+
sub import {
- my $pkg = caller;
+ shift;
+ my @opts = @_;
+
+ my %exports = %default_exports;
+
+ for (my $i = 0; $i <= $#opts; ++$i) {
+ my $feature = $opts[$i];
+ next unless defined $feature;
+
+ my $args;
+ if ($i < $#opts and defined $opts[$i+1] and ref $opts[$i+1] eq 'ARRAY') {
+ ++$i;
+ $args = $opts[$i];
+ } else {
+ $args = [ ];
+ }
+
+ my $handler = $features{$feature};
+ die "Unknown feature '$feature'" unless defined $handler;
+
+ my %syms = $handler->(@$args);
+
+ $exports{$_} = $syms{$_} for sort keys %syms;
+ }
- export_to_pkg \%exports => $pkg;
+ export_to_pkg \%exports => scalar caller;
}
my $test_sub = sub {