[sf-perl] exporting tags
Michael Friedman
friedman at highwire.stanford.edu
Mon Aug 6 12:49:28 PDT 2007
From the Exporter perldoc (under "Specialized Import Lists"):
If you just want to import extra names in addition
to the default set you will still need to include
:DEFAULT explicitly.
I can't tell you why, but that seems to be the way it's supposed to
work.
-- Mike
On Aug 6, 2007, at 12:26 PM, David Alban wrote:
> Greeings,
>
> I have:
> package My::Module;
>
> ...
>
> BEGIN {
> ...
> @EXPORT = qw(
> &sub_1
> &sub_2
> &sub_3
> );
>
> @EXPORT_OK = qw(
> $scalar_1
> $scalar_2
> );
>
> %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.)
>
> Thanks.
> David
> --
> Live in a world of your own, but always welcome visitors.
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
---------------------------------------------------------------------
Michael Friedman HighWire Press
Phone: 650-725-1974 Stanford University
FAX: 270-721-8034 <friedman at highwire.stanford.edu>
---------------------------------------------------------------------
More information about the SanFrancisco-pm
mailing list