There should be absolutely no difference between
$ENV{'PLATFORM'}="abcdef";
and
$variable="PLATFORM"; $ENV{$variable}="abcdef";
I'm noticing a lot of ugly style in your code, a lot of unnecessary code, but nothing that should stop it from working. The following works for me.
use strict; if (@ARGV){ print $ENV{PLATFORM}, $/; exit; } while(<DATA>){ chomp; my ($variable, $value) = split '='; $ENV{$variable}=$value; } system("perl", $0, "test"); __DATA__ PLATFORM=abcdef
In particular, you don't need to use "$variable", just $variable. You don't need to seek to the begining of a file handle you just opened. You don't need to chomp the components if you already chomped the variable they were split from. But none of that should really cause problems. Are you sure that your code is actually being run? That is, you've got the assignment to %ENV inside an if on your open. Do you have an else telling you if the open failed? Could you add code to print out $variable and $value when you're setting them to make sure they really have what you expect?

In reply to Re^3: Setting environment variables by reading them from a configuration file by Eimi Metamorphoumai
in thread Setting environment variables by reading them from a configuration file by robby123

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.