Perlito5
view release on metacpan or search on metacpan
lib/Perlito5X/Exporter.pm view on Meta::CPAN
"on this architecture" );
}
if (@failed) {
die ("Can't continue after import errors");
}
}
}
warn "Importing into $callpkg from $pkg: ", join( ", ", sort @imports ) if $Exporter::Verbose;
foreach $sym (@imports) {
# shortcut for the common case of no type character
unless ( $sym =~ s/^(\W)// ) {
*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"};
next;
}
$type = $1;
no warnings 'once';
*{"${callpkg}::$sym"} =
$type eq '&' ? \&{"${pkg}::$sym"}
: $type eq '$' ? \${"${pkg}::$sym"}
: $type eq '@' ? \@{"${pkg}::$sym"}
: $type eq '%' ? \%{"${pkg}::$sym"}
: $type eq '*' ? *{"${pkg}::$sym"}
: do { die ("Can't export symbol: $type$sym") };
}
}
sub export_to_level {
my $pkg = shift;
my $level = shift;
(undef) = shift; # XXX redundant arg
my $callpkg = caller($level);
$pkg->export( $callpkg, @_ );
}
# Utility functions
sub _push_tags {
my ( $pkg, $var, $syms ) = @_;
my @nontag = ();
my $export_tags = \%{"${pkg}::EXPORT_TAGS"};
push(
@{"${pkg}::$var"},
map { $export_tags->{$_} ? @{ $export_tags->{$_} } : scalar( push( @nontag, $_ ), $_ ) }
(@$syms) ? @$syms : keys %$export_tags
);
if ( @nontag and $^W ) {
die ( join( ", ", @nontag ) . " are not tags of $pkg" );
}
}
sub require_version {
my ( $self, $wanted ) = @_;
my $pkg = ref $self || $self;
return ${pkg}->VERSION($wanted);
}
sub export_tags {
_push_tags( (caller)[0], "EXPORT", \@_ );
}
sub export_ok_tags {
_push_tags( (caller)[0], "EXPORT_OK", \@_ );
}
1;
( run in 0.498 second using v1.01-cache-2.11-cpan-800906f7e73 )