From perrin@primenet.com Thu Jun 1 05:57:01 2000 Return-Path: Mailing-List: contact modperl-help@apache.org; run by ezmlm Delivered-To: mailing list modperl@apache.org Received: (qmail 34651 invoked from network); 1 Jun 2000 05:57:01 -0000 Received: from medusa.mminternet.com (root@207.175.72.15) by locus.apache.org with SMTP; 1 Jun 2000 05:57:01 -0000 Received: from charlotte (elem.com [216.86.192.30]) by medusa.mminternet.com (8.9.3/8.9.3) with SMTP id WAA20779; Wed, 31 May 2000 22:56:54 -0700 Message-ID: <005501bfcb8f$7d2fa6e0$0b00a8c0@sanvicente.org> From: "Perrin Harkins" To: "Philip Mak" , References: Subject: Re: Human readable flatfiles Date: Wed, 31 May 2000 23:06:12 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N > I have a perl (non-modperl) program that needs some input data. Currently, > it reads in the data by "require"ing another perl script that has > statements to set the variables (as global variables). I did it this way > so that I can easily edit the include file if I want to change values, > and I can even put code in the include file to calculate values. > > But, I am finding that this does not work in modperl under "use strict". > Apparently, code in a file called by require is not in the same variable > scope. (If "use strict" is off, it works sometimes but other times the > variables come out with the values from the previous invocation.) You need to read up a little on modules and "require" in Perl5. The quick and dirty solution is to use "do" instead of require. That will solve your immediate problem, but you'll still be reading the files every time which might eventually become a performance hit. What I do when I have things like config files is make actual unique packages of them. For example: (In My/Module.pm) package My::Module; # don't use strict here $foo = 7; (In some other program) use My::Module; print "$My::Module::foo\n"; Honestly though, your example makes it look like you'd be better off with dbm files and Tie::MLDBM or something. - Perrin