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.


In reply to Importing multiple %EXPORT_TAGS by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.