in reply to Re: use constant and exporter
in thread use constant and exporter

Ok, the code now reads:
package MyPackage; use Data::Dumper; use 5.006; #use Data::Validate::OO::Tests; use Tests; #use constant { # VALID => 1, # INVALID => 2, # ERROR => 0, # }; use constant VALID => 1; use constant INVALID => 2; use constant ERROR => 0; use strict; use warnings; require Exporter; use AutoLoader qw(AUTOLOAD); our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => ['VALID','INVALID','ERROR'], 'codes' => ['VALID','INVALID','ERROR'], ); our @EXPORT_OK = @{ $EXPORT_TAGS{'all'} }; our @EXPORT = qw(); #Intentionally left blank our $VERSION = v0.0.1;
And I'm testing it with this:
use MyPackage qw(:all); use Data::Dumper; use strict; use warnings; print STDOUT VALID;


It still yields the same error...



My code doesn't have bugs, it just develops random features.

Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

Replies are listed 'Best First'.
Re: Re: Re: use constant and exporter
by tall_man (Parson) on Jan 28, 2003 at 05:28 UTC
    I took your example exactly Flame, except that I commented out the "use Tests" (I don't have that module) and the "use Autoloader" (it causes errors if the package isn't installed, and I was testing it from the current directory). The example worked with no problem.

    (It also works with MyPackage::VALID, but I wouldn't call that an import.)

    I'm wondering if perhaps you aren't testing the package you think you are. Is the right copy of MyPackage.pm in your @INC path first? Did you reinstall the package after making the changes?

      The package is in the same directory as the one I'm testing this in. It's part of my testing as I write mypackage (named, for now, Data::Validate::OO). (Reference: Data Validation Tests, further references linked to from there.)

      I'll see what happens if I remove a few lines here and there...



      My code doesn't have bugs, it just develops random features.

      Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

Re^3: (nrd) use constant and exporter
by newrisedesigns (Curate) on Jan 28, 2003 at 05:14 UTC
    use MyPackage qw(:all); use Data::Dumper; use strict; use warnings; print STDOUT MyPackage::VALID;

    Untested.

    John J Reiser
    newrisedesigns.com

      Well that does work, but I was hopeing to actually be able to export it...



      My code doesn't have bugs, it just develops random features.

      Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)