tags:

views:

48

answers:

1

Aite, I met a weird thing today with PERL. Couldn't understand:

file a.pl:

$x = $ENV{$x}."123";
$x = "weird";
system("b.out");
#there is no such $ENV{$x}=.... in this file. It is executed directly from "make"
#and "make" also doesn't have any lines which set environment variables.....

However, b.out somehow can read $x value as an environmental variable. I think there should be some kinda of configuration so $x is connected & autoset value for $ENV{$x}. Just on top of my head. My OS is Linux, fyi.

Any ideas? Thanks.

A: 

sounds weird. would you please provide more info. about (how and what env. variable are read by b.out) and (value of $x before this part of code)?

if you really to do this, to myself, a more explicital way is to bind $x to $ENV{'xxx'} by using reference. so that changes made to $$x will change environment variables in subshell invoked by system.

jokester