[EMAIL PROTECTED] wrote:

> Dear Perlgurus,
> 
> I've got a problem, reading an environment variable.
> My environemt: Windows XP/2000 Perl 5.6.. If possilbe, I don't want to update 
> to 5.8.
> 
> First I start the following cmd file:
> 
> --- begin ---
> SET FOO_TOKEN=BAR
> CALL SET %FOO_TOKEN%_DIR=c:bar

CALL SET %FOO_TOKEN%_DIR=c:\bar         # added \

> --- end ---
> 
> After that I start in the _same_ environment (cmd) the following perl code:
> 
> --- beginn ---
> use strict;
> use warnings;
> 
> my $foo_token_dir   = "%%FOO_TOKEN%_DIR%";
> my $foo_token_value = "";
> 
> $foo_token_value = $ENV{ $foo_token_dir };
> #$foo_token_value = $ENV{ BAR_DIR };
> 
> print "foo_token_dir:   " . $foo_token_dir   . "n";
> print "foo_token_value: " . $foo_token_value . "n";
> --- end ---

I don't really follow what you're doing, but I would just go with :

my $foo_token = $ENV{FOO_TOKEN};
print "foo_token: $foo_token\n";
my $foo_token_dir = $ENV{"${foo_token}_DIR"};
print "foo_token_dir: $foo_token_dir\n";

Which prints:
foo_token: BAR
foo_token_dir: c:\bar

If that's what you really want.  I don't know why you would print out %'s
unless you were redirecting to another .bat file - in which case you could
always add the %'s back in.

> My output is:
> 
> foo_token_dir:   %%FOO_TOKEN%_DIR%
> Use of uninitialized value in concatenation (.) or string at <script>  line 
> 11.
> foo_token_value:
> 
> which I understand is not the problem.
> 
> I want the following output:
> 
> foo_token_dir:   %%FOO_TOKEN%_DIR%
> foo_token_value: c:bar
> 
> So how can I get a result for the envinment variable "%%FOO_TOKEN%_DIR%" in
> perl? I don't want to use the expression $foo_token_value = $ENV{ BAR_DIR };
> (line 8).
> 
> The script seems a little bit strange, but I stripped down my problem
> to this. If necessary, I can tell more about the reasons, why I did it that 
> way, .


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to