Dan Muey wrote: > I guess my main question would boil down to :: > > How can I use variables that get declared in a lib file in a script that uses -w and >use strict; ? > > A more complex example of what I've tried and what I'm trying to get is here :: > > On the script below, when use strict is commented out :: > Name "main::dog" used only once: possible typo at ./test.pl line 11. > Content-type: text/html > > Use of uninitialized value at ./test.pl line 11. > Error: ::HI > > And this when use strict; is not commented out I get :: > Global symbol "$dog" requires explicit package name at ./test.pl line 11. > Execution of ./test.pl aborted due to compilation errors. > > If I uncomment the my $dog in the script then all is well. Except the lib won't >change th value of $dog even if I take of the 'my' in the lib. > > #!/usr/bin/perl -w > > use strict; > #my $dog = 'bart'; > eval { > use lib '/home/dmuey'; > require "lib.lib"; > }; > print "Content-type: text/html\n\n"; > print "Error: $@ :: $dog ::\n"; > > :: lib.lib file is :: > > my $dog = 'joe'; > 1;
HI Dan, Well, we don't see what is happening in the lib file, so that leaves us largely in the dark. You might also note that line 10 seems to be the last line of the script, unless you have dited something out. I would suggest simply not using a lib file in this way. I see the use and require statements, but no calls to functions defined therein. It might make sense to define a global constant this way in a lib file, but not a raw variable. For instance, it probably makes more sense to use a Math module which defines PI once, than to hard-code the definition in each script. It defeats the purpose of programming, by obscuring the source of your action, to do this with instance data.. What purpose did you mean to serve by hard-coding this data in an imported file? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]