The idea of creating a package is clear, but it doesn't solve the problem at hand. What I want is a possibility for non programmers to change the global variable to reflect to their server (e.g. path to sendmail, email address, currency symbol etc.) environment without messing with the perl codes.
What I don't understand - is why my scripts get only the first variable in the config file, but fail on the rest. Babs -----Ursprüngliche Nachricht----- Von: Randy W. Sims [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 14. März 2004 19:07 An: B. Fongo Cc: [EMAIL PROTECTED] Betreff: Re: Problem using require() On 3/14/2004 9:58 AM, B. Fongo wrote: > I have several modules which needs global variables from a text file > (global.txt). > Within each module, I use require "global.txt" to get my variables. > ---------------------------------------------------------------- > global.txt > ---------------------------------------------------------------- > $shop = "Shop name"; > $sendmail = "/usr/./sendmail"; > $email = "[EMAIL PROTECTED]"; > and so on. > --------------------------------------------------------------- > > > But strangely enough, all my modules get the first variable in text file > and warm that the rest are uninitialized. > I'm a bit confused on what that might mean. The usual idiom is to create a Config package for your module: package MyModule::Config; use strict; use vars qw($shop $sendmail $email); $shop = "Shop name"; $sendmail = "/usr/./sendmail"; $email = "[EMAIL PROTECTED]"; # Constants use constant $var_that_should_not_change_value => 1; ... __END__ Then in your module: use MyModule::Config; print $MyModule::Config::shop; ... You can use Exporter (see perldoc Exporter) if you want to access the variables without their fully qualified names. Regards, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>