Without seeing what is inside env.conf - i can only guess that PARAM will be there. But you have other issues - you are never opening a file handle for env.conf -
open(FILE,'../env.conf') or die "not there";
now you can either slurp the contents into an array or a scalar, or iterate through the file one line at a time. Small files can use the former technique without a hitch, but the latter technique is better for huge files. Since you are splitting on new lines - let's use a scalar:
my $content = do {local $/; <FILE>};
Next, don't use %ENV - use your own hash, how about
my %conf = map { /^([^=]+)=(.*)$/; $1 => $2 } split /\n/, $content;
but that doesn't quite work - if it reads '=bar' then you will have an undefined key that points at the value 'bar'. map is fine and dandy for data transformation, but as soon as the logic inside the code block gets tricky, i like to find another way. Let's try a while loop on an open file handle:
my %conf; while (<FILE>) { chomp; my ($k,$v) = $_ =~ /^([^=]+)=(.*)$/; $conf{$k} = $v if $k; }
Hope this helps!

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

In reply to (jeffa) Re: How to assign a variable with a value read from a config file by jeffa
in thread How to assign a variable with a value read from a config file by tariqahsan

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.