xorl has asked for the wisdom of the Perl Monks concerning the following question:

This is on a Win2k box using activestate perl 5.6

If I set an environmental variable like this $ENV{ORACLE_HOME}="C:\\foobar\\Ora9\\";

Will it affect anything else?

When I went to the Windows control panel/system/advanced/environmental variables and set ORACLE_HOME there it broke some other jobs running on the box (I'm not even going to try to pretend I understand why they have a different value for that variable).

Anyway I need to make sure I can set the environmental variable just for the script and not have it leak over to anything else. What's the best way of doing this?

Thanks

Replies are listed 'Best First'.
Re: Setting Environmental variables
by JediWizard (Deacon) on Oct 08, 2004 at 13:26 UTC

    You should be safe. Changes made to %ENV will only last for the duration of your script, and will only be visible to it, and any children processes it might spawn.

    May the Force be with you
Re: Setting Environmental variables
by ww (Archbishop) on Oct 08, 2004 at 17:16 UTC
    SPECULATIVE: If you haven't reviewed this (from w2k help|environ....localizing.... ) already, it may offer a hint if you can run the script out of a batch (batwrap).

    "Setlocal

    "Begins localization of environment variables in a batch file. Localization lasts until a matching endlocal command is encountered, or the end of the batch file is reached

    "setlocal option

    "Parameter

    "option

    "When command extensions are enabled (the default in Windows 2000), the setlocal batch command accepts an optional argument, which can be either enableextensions or disableextensions. This enables or disables the command extensions until the matching endlocal command, regardless of their setting prior to the setlocal command.

    "The setlocal command also sets the errorlevel value when it is passed an argument. The errorlevel value is set to zero (0) if one of the two valid arguments is given and set to one (1) otherwise."