Hi,

first time I answer myself ;-). Here's my solution:

I cut off the cmd-file for the example and set the env var in the script. After all, the value of the env var "%%FOO_TOKEN%_DIR%" will be created without using the env vars "FOO_TOKEN" or "BAR_DIR" directly.

The idea was to use the system command set and redirect the output of that statement. The analyse of the output is quite simple.

Thanks to Bill, who said, that the command "set %FOO_TOKEN%_DIR" works properbly in the shell.

Here is the script:

--- beginn ---

use strict;
use warnings;

# init
$ENV{ FOO_TOKEN }   = "BAR";
$ENV{ BAR_DIR }     = "c:\\bar";
my $foo_token_dir   = "";
my @foo_indirect    = "";
my $foo_token_value = "";
# end of init

# set the var as you like
$foo_token_dir   = "%%FOO_TOKEN%_DIR%";
#$foo_token_dir   = "%BAR_DIR%";

# main

$foo_token_dir =~ s/^%//;
$foo_token_dir =~ s/%$//;

# in real life, don't forget to check the index and the output!
@foo_indirect    = `set $foo_token_dir 2>&1`;
$foo_token_value = $foo_indirect[ 0 ];
$foo_token_value =~ s/^\s+//;
$foo_token_value =~ s/\s+$//;
$foo_token_value =~ s/([^=]+)=(.*)/$2/ ;

print "foo_token_dir:   " . $foo_token_dir   . "\n";
print "foo_token_value: " . $foo_token_value . "\n";

# end of script

Bye
Karl-Heinz

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to