> > 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 Sure you see what's going on, look above for the line -> :: lib.lib file is ::
All it has is my $dog = 'joe'; 1; > 10 seems to be the last line of the script, unless you have > dited something out. Before I created a complex bunch of scripts I wanted to have the foundation, basically configuration settings, set good. > > I would suggest simply not using a lib file in this way. I > see the use and require statements, but no calls to functions There will be functions later. > defined therein. It might make sense to define a global > constant this way in a lib file, but not a raw variable. For Well, any other ideas on how I can have a hundred scripts all use the same settings and make it easy to change any of them at will without having to go edit a hundred files would be nice. > instance, it probably makes more sense to use a Math module > which defines PI once, than to hard-code the definition in True but pi never changes, the settings for the scripts using it will. > 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? To share configuration variables in one place for lots and lots of scripts to use instead of having to put them in each script and then on echanges and having to go through a hundred scripts all over the place to change them. Someone else already helped me get it nailed down pretty well, basically the my was killing me and I needed to add use vars... Any other insights will be welcome. Thanks Dan > > Joseph > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]