Well, you have a choice:

if you declare them with "our" in the main program
then you get to them in other packages via
Main::<varname> or ::<varname>, if you declare them
with "our" in the require'd file, then you reference
them in the main program with <package>::<varname>, where
<package> is the name of the package that the require'd
file declares.

If you want to get fancy, declare them in the package
file, have the package "use Exporter" and define which
variables should always export into the client's namespace
(i.e. the namespace of the package doing the "use" or 
"require") and which should never export, and which should
export only when asked by the client.

-Peter

> -----Original Message-----
> From: Roland Corbet [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 01, 2001 7:59 AM
> To: Peter Vogel; [EMAIL PROTECTED];
> [EMAIL PROTECTED]
> Subject: RE: Using "my" with "require" files
> 
> 
> At 16:51 31/01/2001, Peter Vogel wrote:
> >my is what it implies - it declares a variable local to that scope.
> >
> >What you want is "our" which works the same as "my" but declares
> >the variable to be in global scope, it replaces the Perl 5.5 method
> >of "use vars qw(<varlist>)"
> >
> >-Peter
> 
> After using "our" on the variables in the required file, I 
> decided to "use 
> strict;" on the file that calls the required file.  Running 
> the script from 
> the command line showed that the script wanted me to define 
> the variables 
> again, with an error message like:
> 
> Global symbol <variable/list/hash name> required explicit 
> package name at 
> line x.
> 
> I take it from this that I have to define any variables in 
> the main script 
> that I want to use from the required script, even though I've 
> declared them 
> in the required file using "our".
> 
> Thanks for your help,
> 
> Regards
> 
> Roland
> 
> 
> -- 
> The information contained within this e-mail sent by Cradley 
> Print Ltd. is
> confidential and is intended for the named recipient only. If 
> you are not
> the intended recipient please notify us by telephone 
> immediately on 01384
> 414100 (UK)or +(44)1384 414100 (International) or return it 
> to us by e-mail
> quoting the name of the sender and the addressee. Please then 
> delete it from
> your system.
> 
> Encryption and Viruses
> ==================
> Please note that this e-mail and any attachments have not 
> been encrypted.
> They may therefore be liable to be compromised. Please also 
> note that it is
> your responsibility to scan this e-mail and any attachments 
> for viruses.
> Viruses and compromises of security are inherent risks in relation to
> e-mail.
> 
> We do not, to the extent permitted by law, accept any 
> liability (whether in
> contract, negligence or otherwise) for any virus infection 
> and/or external
> compromise of security and/or confidentiality in relation to 
> transmissions
> sent by e-mail.
> 
> Contracts
> ========
> Please note, that contracts may NOT be concluded on behalf of 
> Cradley Print 
> Ltd by e-mail, but contracts on behalf of our clients may be 
> concluded by 
> e-mail.
> 
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to