in reply to printing enviroment vars from regex
No need to use a regex:
Output:my @output = split(/\n/, `set`); my %environment; foreach (@output) { my ($key, $value)= split /=/; $environment{$key}=$value; } foreach $variable qw/USERNAME HOMEDRIVE/ { ${$variable}=$environment{$variable}; } print "my name is $USERNAME my home is at $HOMEDRIVE";
I had to adapt the environment variables a bit as I'm on Windows XP.my name is KJM my home is at C:
Update: I should have used the %ENV-hash, but TIMTOWTDI!
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: printing enviroment vars from regex
by RnC (Sexton) on Aug 03, 2004 at 15:15 UTC |