stevieb has asked for the wisdom of the Perl Monks concerning the following question:
Hey all, I hope you've all had/are having a wonderful holiday!
I'm having a Rubber Duck Debugging moment here... I am using @EXPORT_OK to export my public functions within a module, and all are available through an :all tag, but for my test suite, I want to have an extra tag that exports a few of my private functions as well, but can't seem to be able to import them. Here's what I've got:
Module:
package MyPackage; use strict; use warnings; use Exporter qw(import); our @ISA = qw(Exporter); our @EXPORT_OK = qw( func_one func_two ); our @EXPORT_PRIVATE = qw( _private_one _private_two ); our %EXPORT_TAGS = ( all => \@EXPORT_OK, private => \@EXPORT_PRIVATE, )
Test script:
use warnings; use strict; use MyPackage qw(:all :private); ...
When I run the script, I get:
"_private_one" is not exported by the MyModule module "_private_two" is not exported by the MyModule module Can't continue after import errors at ... line .... BEGIN failed--compilation aborted at ... line ...
I *thought* I'd done this before, but it turns out although I have other modules that have multiple tags, I've only ever tried to import one at a time, not multiple at once.
I'm sure I'm just having a brain fart moment here. Could someone please point out what I'm missing, or is this importing of multiple tags something that isn't available and I'm just finding out now?
Cheers,
-stevieb
Update: I just thought of something... I suppose I could insert the @EXPORT_OK array into the @EXPORT_PRIVATE one and then simply import the :private tag by itself, but now I'm curious as to whether that's the only way forward or not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Importing multiple %EXPORT_TAGS
by choroba (Cardinal) on Dec 28, 2020 at 00:30 UTC | |
by stevieb (Canon) on Dec 28, 2020 at 00:34 UTC | |
by stevieb (Canon) on Dec 28, 2020 at 00:39 UTC | |
by jcb (Parson) on Dec 28, 2020 at 01:57 UTC | |
by stevieb (Canon) on Dec 28, 2020 at 04:44 UTC | |
by jcb (Parson) on Dec 29, 2020 at 03:52 UTC | |
|
Re: Importing multiple %EXPORT_TAGS
by Anonymous Monk on Dec 28, 2020 at 02:26 UTC | |
by Corion (Patriarch) on Dec 28, 2020 at 07:08 UTC | |
by stevieb (Canon) on Dec 28, 2020 at 10:04 UTC | |
by perlfan (Parson) on Dec 28, 2020 at 18:11 UTC | |
by stevieb (Canon) on Dec 28, 2020 at 18:52 UTC |