in reply to Re^2: Can I do this ???
in thread Can I do this ???

Windows batch processing.

@REM -------------------------------- @REM runme.cmd @echo off SET FOO=bar echo %FOO% echo Calling setter.cmd call setter.cmd echo After setter.cmd echo %FOO%
@REM --------------------------------- @REM setter.cmd echo "I am in setter." set FOO=biz echo Setters FOO = %FOO%
-------------------------------------- output -------------------------------------- bar Calling setter.cmd "I am in setter." Setters FOO = biz After setter.cmd biz

The called sub command, setter.cmd, resets the environment of the caller.

--MidLifeXis

Replies are listed 'Best First'.
Re^4: Can I do this ???
by BrowserUk (Patriarch) on Jan 22, 2009 at 15:51 UTC

    The reason that works is because there is no child process involved.

    The called script is processed by the calling process--in the same fashion as Perl's do script.pl;--and the changes are made to the current process' environment by the current process.

    The effect is exactly the same as:

    ## Called .pl $::ENV{ somekey } = 'somevalue'; ##calling script; do 'called.pl';

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Very true, and I should have made that point clear.

      What I meant to demonstrate is that a "typical" windows batch mode programming style (well, what I saw when I was in an environment where I had to care about those scripts) allows, even encourages, modifying the "parent" process from things that are called.

      --MidLifeXis