1package alias::module; 2 3our $DATE = '2018-12-15'; # DATE 4our $VERSION = '0.002'; # VERSION 5 6 7sub import { 8 my $class = shift; 9 my $noreq = $_[0] eq '-norequire' ? shift : 0; 10 my $orig = shift; 11 12 my $caller = caller(); 13 14 unless ($noreq) { 15 (my $orig_pm = "$orig.pm") =~ s!::!/!g; 16 require $orig_pm; 17 } 18 *{$caller . "::"} = \*{$orig . "::"}; 19} 20 211; 22# ABSTRACT: Alias one module as another 23 24__END__ 25 26=pod 27 28=encoding UTF-8 29 30=head1 NAME 31 32alias::module - Alias one module as another 33 34=head1 VERSION 35 36This document describes version 0.002 of alias::module (from Perl distribution alias-module), released on 2018-12-15. 37 38=head1 SYNOPSIS 39 40 package Your::Alias::Name; 41 use alias::module 'Some::Real::Module::Name'; 42 43To avoid require()-ing: 44 45 use alias::module '-norequire', 'Some::Real::Module::Name'; 46 47=head1 DESCRIPTION 48 49This module aliases one module name to another. 50 51 package Your::Alias::Name; 52 use alias::module 'Some::Real::Module::Name'; 53 54is equivalent to: 55 56 package Your::Alias::Name; 57 BEGIN { 58 $Package::Alias::BRAVE = 1; 59 require Some::Real::Module::Name; 60 } 61 use Package::Alias 'Your::Alias::Name' => 'Some::Real::Module::Name'; 62 63except that this module does not use L<Package::Alias> and is simpler. It is 64useful if you want to let users access a module's functionality under a 65different (usually shorter) name. 66 67=head1 HOMEPAGE 68 69Please visit the project's homepage at L<https://metacpan.org/release/alias-module>. 70 71=head1 SOURCE 72 73Source repository is at L<https://github.com/perlancar/perl-alias-module>. 74 75=head1 BUGS 76 77Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=alias-module> 78 79When submitting a bug or request, please include a test-file or a 80patch to an existing test-file that illustrates the bug or desired 81feature. 82 83=head1 SEE ALSO 84 85L<Package::Alias> 86 87L<abbreviation> 88 89=head1 AUTHOR 90 91perlancar <perlancar@cpan.org> 92 93=head1 COPYRIGHT AND LICENSE 94 95This software is copyright (c) 2018 by perlancar@cpan.org. 96 97This is free software; you can redistribute it and/or modify it under 98the same terms as the Perl 5 programming language system itself. 99 100=cut 101