perlpipe has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to write a Perl module that exports a group of names and I can't seem to get it to work. It must be something obvious that I am not seeing.

This is my module in the file "tmod.pm" in the current directory:

package tmod; use 5.20.0; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw($v0 $v1 $v2); our %EXPORT_TAGS = (tag_v0=>[qw($v0)]); our $v0=0; our $v1=1; our $v2=''; 1;

And this is my test script:

use 5.20.0; use strict; use warnings; use Carp; use tmod qw(tag_v0); say "done"; exit;

The result is:

perl test_tmod.pl "tag_v0" is not exported by the tmod module Can't continue after import errors at test_tmod.pl line 5. BEGIN failed--compilation aborted at test_tmod.pl line 5.

I am running Citrus Perl 5.24.01 under Windows 10

All help will very much appreciated.

David

Replies are listed 'Best First'.
Re: EXPORT_TAGS does not export a defined tag
by Athanasius (Archbishop) on Nov 30, 2017 at 03:38 UTC

      Thanks everyone for your answers. I knew the answer was straight forward and I just couldn't see it.

Re: EXPORT_TAGS does not export a defined tag
by huck (Prior) on Nov 30, 2017 at 03:39 UTC
Re: EXPORT_TAGS does not export a defined tag
by choroba (Cardinal) on Nov 30, 2017 at 08:36 UTC
    See also the note under What Not to Export:
    There's one more item to add to this list. Do not export variable names. Just because Exporter lets you do that, it does not mean you should.
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: EXPORT_TAGS does not export a defined tag
by beech (Parson) on Nov 30, 2017 at 03:43 UTC
Re: EXPORT_TAGS does not export a defined tag
by stevieb (Canon) on Nov 30, 2017 at 04:22 UTC

    Here's the repetitive way I've populated and offered things. This shows the usage.

    I admit that it was the first time I've done anything regarding exporting items such as this in this way, so I'm just throwing it out there (feedback welcome :)

    The other Monks have expressed exactly what the problem is here so I'll digress from that, but from you OP, feedback on what documentation may look like would be wonderful.

    -stevieb