Using environmental variables

I have a question about reading in environmental variables. The below line doesn't seem to set the variable correctly. I start OptiPerl from command line with the correct environment but it doesn't have any impact on reading in enviromental variables. I'm I doesn't something incorrectly or does OptiPerl support this feature. The perl programs I write in many cases rely on environmental variables.

my $path="$ENV{'Path'}";

Answer:
The way you start optiperl is not important, as the environment variables are controlled within the program.

First of all do you mean the arguments of the script? You can control these from Run menu / Arguments. These are read afterwards in the script like this

foreach (@ARGV) {
 print "$_\n";
}

For the environment, this is controlled from the Query menu / Open query editor / Environment tab. These are read the following way:

foreach (sort keys %ENV) {
print "$_ = " . $ENV{$_} . "\n";
}

When you select "Run / Run in browser" the environment set-up looks like that in the query editor in pages Environment and Preview.

If you want to test environment variables in console scripts, here are two things you can do:

1) Add the environmental variables you need in the query editor in page "environment". Also make sure to select afterwards menu Query / Add values, so the settings are saved with the script.

2) Menu Run / Run in console. When running in the console the environent is not modified, and the environment set up in Windows is used.

22.06.2003. 11:44

This article hasn't been commented yet.

Write a comment

:

:

:


7 + 6 =