Hi all I've got the basic hang of scope of vars in Perl which is a bit different to other languages I've used.
Having split a large program into packages I would like to use a global var across multiple packages. Perl does not seem to have a 'C' type 'extern' command to say a var is declared in another package. Perhaps it does not need one ? Would I be correct in thinking that the %DataFromHTMLPage in the following example would always be pointing to the same bit of memory across the packages ? "myglob.pm" package myglob; use strict; use CGI::Carp qw(fatalsToBrowser); require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(%DataFromHTMLPage); our %DataFromHTMLPage; --------------------------------- "myscript.pl" use strict; use CGI::Carp qw(fatalsToBrowser); use myglob; use mypkg1; use mypkg2; # load data into %DataFromHTMLPage and do stuff with it -------------------------------------- "mypkg1.pm" package mypkg1; use strict; use CGI::Carp qw(fatalsToBrowser); use myglob; #Do stuff here with %DataFromHTMLPage using functions etc ----------------------------------------- "mypkg2.pm" package mypkg2; use strict; use CGI::Carp qw(fatalsToBrowser); use myglob; #Do stuff here with %DataFromHTMLPage using functions etc If I don't "use myglob" in the package files then strict causes an error to say that %DataFromHTMLPage is undefined. My main question is if you define a var with 'our' if there is a 2nd/3rd occurance of the definition of it what happens ? Hope the above makes some sense ! ;) Thanks in advance Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>