in reply to use constant and exporter

It should work like this. I know I've exported constants before, anyway.
package MyPackage; use 5.006; use strict; use warnings; use Data::Dumper; use constant VALID => 1; use constant INVALID => 2; use constant ERROR => 0; use base qw(Exporter); our @EXPORT_OK = qw(VALID INVALID ERROR); our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK, 'codes' => [ qw(VALID INVALID ERROR)], ); our @EXPORT; #Intentionally left blank our $VERSION = v0.0.1;

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: use constant and exporter
by Flame (Deacon) on Jan 28, 2003 at 22:15 UTC
    Hmm, that didn't seem to work at first... but I think I solved my problem. I wasn't really using package MyPackage... the package was Data::Validate::OO and I was using "use OO" because I was testing from within the same dir as Data::Validate::OO was being written in... so... it looks like it was failing to call export properly... I'm now using 'use lib' to use the full package name and it works again.



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

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

      Well, that explains it. use Foo does this:
      BEGIN { require Foo; Foo->import; }
      If you use OO, require will find your module, but of course the module will still create the Data::Validator::OO package and not an OO package, causing the following OO->import to fail (silently).

      Makeshifts last the longest.

        Yah, the funny thing is, I think I knew about that once... then forgot about it... Oh well... thanks for the suggestions, at least your versions are better looking than mine. Encouraged me to clean up what I had :)



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

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