Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share "constant" among many modules 1

Status
Not open for further replies.

rubis

Programmer
Jun 21, 2001
54
GB
I had this problem before so it might be useful for someone


package Global;
use strict;
require Exporter;
use vars qw(@ISA @EXPORT);

@ISA = qw(Exporter);
@EXPORT = qw(A B);

use constant A => "A";
use constant B => "B";

1;


within the caller one use "Global::A"... e.g. $a = Global::A

so now u can share constant among many modules

 
Hi Rubis,
I am having the exact same problem than you did and however that doesn't solve it. I have my Config package as your Global one. If I try to print the constant directly in the Config package that works fine. Though, in the other module that doesn't ... I tried use/require Config, to print Config::A or directly A (was shown like that in other forum..)and no luck. Even, if I tried something like 'use Config qw(A);'it complains saying Config doesn,t export it even if it does as you wrote above...

Any idea?
Thanks,
Eve
 
Hi again,
I found the problem: Config.pm was not a good name since it exists in other packages....

Sorry about that,
Have a great nite!
Eve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top