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

every time the export list changes in Foo::Core, it has to be updated in Foo::Core::Specialized.

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; ## Add, subtract or overwrite as required.

That way F::C::S can export everything F::C can unless you explicitly remove it--self maintaining--plus anything you add or overwrite.


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.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^4: Creating "parasitic" exports
by sirrobert (Acolyte) on Nov 18, 2009 at 18:05 UTC

    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?

      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.