I think what you want to do isn't directly supported by Exporter.  But you could of course reinvent the parts of it you need in slightly modified (and simplified) form:

package Foo; use strict; use warnings; sub import { # print "Foo::import(): @_\n"; # debug shift @_; # first arg not needed here my $dest = caller; for my $what (@_) { if ($what eq ':transforms') { no strict 'refs'; for (qw(transform_one transform_two)) { *{"${dest}::$_"} = *{"Foo::Transforms::$_"}; } } # elsif ... } } package Foo::Transforms; sub transform_one{ return "transform_one(): @_" } sub transform_two{ return "transform_two(): @_" } # ... 1;
#!/usr/local/bin/perl -l use Foo qw(:transforms); print transform_one("xyzabc"); __END__ $ ./831686.pl transform_one(): xyzabc

The difference to the other suggestions is that you wouldn't need to go exporting indirectly via the Foo namespace.  In other words, you could have routines of the same name in Foo::Bar, Foo::Transforms, etc. without risking name clashes in the intermediate Foo namespace... (of course, the mapped final names in the destination package would still have to be unique).


In reply to Re: Exporting symbols from another package by almut
in thread Exporting symbols from another package by crashtest

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.