Ok, your problems are as follows:
  1. Get the "conf" file loaded into memory.
  2. Get the variables that came from the "conf" file into the relevant bits of your program.
  3. Don't upset "use strict."
For loading into memory, you can use "require" or "do." These will basically eval the program. But they don't automagically put the variables into the scope that you require.

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:

package Blackpitch::Conf; our $var1 = "x"; our $var1 = "y";
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; our $Conf = { var1 => 'x', var2 => 'y', };
That will let you get local access to it in various modules and files with a simple
my %Conf = %$Blackpitch::Conf;
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:
$Blackpitch::Conf::var1 = 'x'; $Blackpitch::Conf::var2 = 'y';
...but that is tedious and error-prone.

In reply to Re: Include external variables into script by rlucas
in thread Include external variables into script by blackpitch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.