Matthew Winn wrote:
On Mon, 19 Feb 2007 23:28:08 -0800, ayoub890 <[EMAIL PROTECTED]>
wrote:

I am running a perl script in a command inside make. I am trying to pass an environment variable to perl, modify it inside perl and see it changed inside make after returning from the perl script.

What is happening is that perl see the environment variable and tries to modify it but make sees no change in the value of the environment variable after return from the perl script.

Can someone tell me what I am doing wrong?

Environment variables don't work in the way you think they do. They're
not global. Each process has its own copy of the environment that is
inherited from its parent at the time the process is created.

If you change an environment variable in process A and then create a
new child process B, both will have the same value for the variable.
But now each process can change the variable separately: B's value
came from the value that A had at the time B started, but there's no
longer any connection between them.

If you want to pass a value back from the child to the parent then you
have to do it yourself, sending it back on standard output or storing
it in a file somewhere and having the parent read it.


In a Unix shell, you can do

        VAR = `command arg1 arg2 arg3`

(with backticks) to set environment variable $VAR to the whole stdout output from the command "command arg1 arg2 arg3". You might try and see whether it works in "make" too.


Best regards,
Tony.
--
Oh don't the days seem lank and long
        When all goes right and none goes wrong,
And isn't your life extremely flat
        With nothing whatever to grumble at!

Reply via email to