This is a not-yet-(and perhaps never)-ready-for-primetime idea after looking at this idea for providing a way to export functions (and perhaps other symbols) to an aliased name, except that I wanted to try to create a way to do that with a plain, already existing module which exports in a "normal" way (update: but not necessarily using Exporter). This is not meant to be production code, it is just starting to play with the idea, and so far only exports functions. Toward the end of making this, I did see Exporter::VA, which is fine, but that module requires that the exporting modules use the Exporter module, which not all modules do (such as TheDamian's), or what if a module exports a code reference which does not already exist as a symbol in the module, etc., so there still may be some purpose to this code :-)
Example: #!/usr/bin/perl use strict; use warnings; use Alias::Exporter ( "Test::Foo" => { bar => 'foo' }, "Test::Bar" => { bar => 'baz' }, ); foo(); baz(); # file Test/Foo.pm package Test::Foo; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(bar); sub bar { print "Test::Foo::bar!\n"; } 1; # file Test/Bar.pm package Test::Bar; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(bar); sub bar { print "Test::Bar::bar!\n"; } 1; # the guts: warning - ugly code ahead package Alias::Exporter; use strict; use warnings; sub import { my $class = shift; my %modules = @_; my $package = caller(); for my $module ( keys %modules ) { my %imports = %{$modules{$module}}; my @import_list = keys %imports; eval qq| use $module ( \@import_list ); for my \$var ( \@import_list ) { no strict 'refs'; *{ \$package . "::\$imports{\$var}" } = \\&{\$var}; } |; die $@ if $@; } } 1;

In reply to RFC: Alias::Exporter by runrig

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.