Bob, Exactly what does "our" do? I understand "my" and even "local" but have yet to grasp the "our" concept.
-----Original Message----- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 9:12 AM To: 'Octavian Rasnita'; [EMAIL PROTECTED] Subject: RE: Using strict and configuration files > -----Original Message----- > From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] > Sent: Sunday, May 28, 2000 4:32 AM > To: [EMAIL PROTECTED] > Subject: Using strict and configuration files > > > Hi all, > > I want to use: > > use strict; > > And I want to use a configuration file in a Perl script. > The configuration file uses: > %page1=( > .... > ); > > %page2=( > .... > ); > > This way I get errors if I run the script because the > variables are not > defined with "my". > > I've tried putting in the configuration file: > > my %page1=( > .... > ); > > But this method doesn't work. > > I use a configuration file and I would like to put the > settings only in this > file without modifying the script. > > Is it possible? Yes. In your main program: use strict; require "config.pl"; our ($foo); print "foo is $foo\n"; In your config file: $foo = "Hello, world"; "use strict" applies only to the current file, so you don't need to change your config file. You need to add the "our" declaration to your main program to make "use strict" happy. A more formal way to handle this would be to use a module and import symbols: File MyConfig.pm: package MyConfig; use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw($foo); our $foo = "Hello, world"; 1; Main program: use strict; use MyConfig; print "foo is $foo\n"; If you import a symbol with "use", you don't need the "our" declaration. -- 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]