in reply to Include external variables into script
To get the variables into the parts of your program in which they are needed, your best bet will be to make them package globals to a "config" package. How about changing your config file to read:
Then, where you need to refer to them, just refer to Blackpitch::Conf? Another strategy is to wrap them up in a hashref:package Blackpitch::Conf; our $var1 = "x"; our $var1 = "y";
That will let you get local access to it in various modules and files with a simplepackage Blackpitch; our $Conf = { var1 => 'x', var2 => 'y', };
As far as making use strict happy, you'll want to make sure you "use vars qw($...)" or declare your variables with "our" -- the other option is always to fully qualify them:my %Conf = %$Blackpitch::Conf;
...but that is tedious and error-prone.$Blackpitch::Conf::var1 = 'x'; $Blackpitch::Conf::var2 = 'y';
|
|---|