in reply to Re^3: Creating "parasitic" exports
in thread Creating "parasitic" exports

Why? Why not just initialise F::C::S's EXPORT* vars from F::C's?

package Foo::Core::Specialised; use Foo::Core ':all'; our @EXPORT = @Foo::Core:@EXPORT; our @EXPORT_OK = @Foo::Core::EXPORT_OK; our %EXPORT_TAGS = %Foo::Core::EXPORT_TAGS; <b>## Add, subtract or overwrite as required.</b>

Well, maybe this is the part I don't get. How can I modify the @import list without overwriting the import() function? If I have to overwrite the import() method to be able to modify the args, then the same question applies -- how do I export from F::C?

Replies are listed 'Best First'.
Re^5: Creating "parasitic" exports
by BrowserUk (Patriarch) on Nov 18, 2009 at 19:57 UTC

    Given a::b.pm:

    package a::b; require Exporter; our @ISA = qw[ Exporter ]; our @EXPORT = qw[ foo ]; our @EXPORT_OK = qw[ foo bar qux ]; our %EXPORT_TAGS = ( all => [ @EXPORT_OK ], ); sub foo{ print 'fooey|' } sub bar{ print 'Baaa!' } sub qux{ print 'Qux?!' } 1;

    And a::b::c.pm:

    package a::b::c; use a::b qw[ :all ]; require Exporter; our @ISA = qw[ Exporter ]; our @EXPORT = @a::b::EXPORT; our @EXPORT_OK = ( @a::b::EXPORT_OK, 'sensible' ); our %EXPORT_TAGS = %a::b::EXPORT_TAGS; push @{ $EXPORT_TAGS{ all } }, 'sensible'; sub sensible{ print 'sensible' } 1;

    Then importer.pl:

    #! perl -slw use a::b::c qw[ :all ]; foo(); bar(); qux(); sensible();

    Produces this:

    c:\test>importer fooey| Baaa! Qux?! sensible

    Anything added to a::b.pm will automatically be available for import through a::b::c.pm without modifications.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.