[sf-perl] exporting tags

David Alban extasia at extasia.org
Mon Aug 6 12:26:32 PDT 2007


I have:
  package My::Module;


     @EXPORT = qw(

     @EXPORT_OK = qw(

     %EXPORT_TAGS = ( foo => [ qw( $scalar_1 $scalar_2 ) ] );


When the module is used as:

  use My::Module qw( :foo );

I see the scalars, but not the exported subroutines.  I can do:

  use My::Module qw( :DEFAULT :foo );

which works, but what I'd really like is to be able to do:

  use My::Module qw( :foo );

and get the subs in @EXPORT along with the subs in the :foo tag.

I think I'm missing something.  Is this impossible?

If I just did 'use My::Module;' I'd get everything in @EXPORT.  Why does
that stop if I supply a tag.

What I'm trying to do is define a set of Readonly.pm constants in the
module and let the user decide whether to import them so they don't have
to use the package prefix, or not to import them and have to use the
package prefix.  (Which is why I don't want to export them by default.)

Live in a world of your own, but always welcome visitors.

More information about the SanFrancisco-pm mailing list