> -----Original Message----- > From: Connie Chan [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 15, 2002 9:28 AM > To: [EMAIL PROTECTED] > Subject: our %hash problem when require > > > Some days ago, I've interested in the using of 'our' var, > however, I do have some problem on using this with require. > > ### Lib 1 ### > use strict; > our %abc; > $abc{a} = 1; > $abc{b} = 2; > ### EOF Lib 1 ### > > ### Lib 2 ### > use strict; > our $a = "ME"; > ### EOF Lib 2 ### > > ### Script 1 ### > use strict; > eval { require "lib1.pl" } or die "lib 1"; > eval { require "lib2.pl" } or die "lib 2"; > > print $abc{a}; > ### EOF Script 1 ### > > When I run script 1, Perl throws me the err of 'explicit package', > but if I change to print $a, instead of $abc{a}, I got "ME" > correctly... > Why ?
The "our" declaration is for the current file only, so you need "our" in Script 1. $a is a "special" variable (used in sort blocks), so it gets a "free pass" from use strict, just like all the other special variables ($_, $/, etc.). Generally, experts would advise against using $a and $b as variables in your programs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]