----- Original Message ----- 
From: "L. Neil Johnson" <[EMAIL PROTECTED]>

> I was initially misled by PERL in a Nutshell which
> says, under Namespaces and Packages, "If the package name is null, the
main
> package is assumed. For example, $var and $::var are the same as
> $main::var" (p. 160).  After more reading and testing, it was determined
> that $var really _must_ be qualified as $::var to be seen in the module.

"Perl in a Nutshell" is quite correct here, I think. If the module does not
have a package name (which is rarely the case) then $var, $::var, and
$main::var are all the same thing.

D:\pscrpt>type trial.pm

sub double_it { return $var * 2}
1;

D:\pscrpt>type try.pl

use warnings;
use trial;

$var = 17;
$var++;
$z = double_it();
print $z, "\n";

D:\pscrpt>perl try.pl
36

D:\pscrpt>

I think it's only if trial.pm had a package name (as it normally would) that
'double_it' would have to be coded as either:

sub double_it { return $::var * 2}

or:

sub double_it { return $main::var * 2}


>  Since the qualifier expands these short variable names, and some of the
> lines of code are long as is, I turned away from qualified names.  Right
> now, whenever the definitions change in main::, I simply cut and paste
them
> into the module, and all works well.  But there are four more big data
> arrays that are in development, and I'm tired of cutting and pasting.  (I
> keep thinking about C header files and #define statements...)
>
> Question: What's the best way to handle this situation?  Can I export
those
> offsets from main:: and "use" them in the module? Or is there some pragma
> that can be used to generate compile-time constants with global
visibility?
>  Any suggestion would be appreciated.

Your reference to "#define statements" and "constants" makes me wonder
whether you might want to make use of the constant pragma (see perldoc
constant), but since I can't quite get a picture of the precise scenario, I
can't be sure :-)

Maybe your question is perfectly clear to someone else ..... otherwise you
might have to provide a simple little demo module and script to illustrate
the problem.

Cheers,
Rob

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to