I'm not sure if this is a GOOD idea, but I THINK you can actually get away
with something like this:  In your module, insert a shorter package name,
but keep the module in the same place. So:

        package Foo::Bar::Constants;

        #do stuff here

        package MyConst;
        $ConstantA = "My Constant";

        #add more constants here

Then you can do a 'use Foo::Bar::Constants', and then call the constants via
$MyConst::ConstantA;

The only advantage I can see over just making a MyConst.pm is that you can
organize your module files in a way that doesn't conflict with any existing
modules...

-----Original Message-----
From: David Garamond [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 11:05 AM
To: [EMAIL PROTECTED]
Subject: package name alias (for shorter variable name)


i have several "constants" in a package:

   package Foo::Bar::Constants;
   $alice = {name=>"Alice", low=>-10, high=>21};
   $bruce = {name=>"Bruce Wayne", low=>-17, high=>5};
   $charlie = {name=>"Charlie", low=>-3, high=>3};
   $devon = {name=>"Devon E.", low=>1, high=>29};

and i want to use them in another package:

   package main;
   require Foo::Bar::Constants;
   use Foo::Bar::Functions;

   add_foo(\@a1, $Foo::Bar::Constants::alice, 1, 3);
   add_foo(\@a1, $Foo::Bar::Constants::bruce, 2, -1);

is there a way to refer the constants by a shorter package name (say '
'$X::alice') without having to make the 'Foo::Bar::Constants' an
Exporter? i also prefer not to import '$alice' and the gang to 'main'
because there are lots of constants in 'Foo::Bar::Constants' and many of
them have pretty short and generic names.

thanks in advance.

--
dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to