I got an Array which contains my PATH-Environment. Now I want to go thru this Array using foreach and then process every single entry to test if the path is still valid. If I use
foreach $is (<@tempPath>) {
I'm missing the first 2 entries in my path which do not exist in the filesystem (just for testing).
<output>
Validating Path-Environment C:\Programme\Python23;C:\Programme\pstools;C:\Programme\Perl\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\etc\venus\current\etc;C:\etc\venus\2.1.0\bin;c:\programme\j2re\1.4.1\bin;c:\programme\j2sdk\1.4.1_01\bin;C:\Programme\NcFTP;C:\Programme\GNU\Vim\vim62;C:\Programme\GNU\MinGW\bin;C:\Programme\GNU\MinGW\mingw32\bin Checking "C:\Programme\Perl\bin" Directory C:\Programme\Perl\bin is valid and will stay in Path-Environment Checking "C:\WINNT\system32" Directory C:\WINNT\system32 is valid and will stay in Path-Environment Checking "C:\WINNT"
<output>
If I use
foreach $is (@tempPath) {
all entries are there, but %SystemRoot% does not get translated.
<output>
Validating Path-Environment
C:\Programme\Python23;C:\Programme\pstools;C:\Programme\Perl\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\etc\venus\current\etc;C:\etc\venus\2.1.0\bin;c:\programme\j2re\1.4.1\bin;c:\programme\j2sdk\1.4.1_01\bin;C:\Programme\NcFTP;C:\Programme\GNU\Vim\vim62;C:\Programme\GNU\MinGW\bin;C:\Programme\GNU\MinGW\mingw32\bin
Checking "C:\Programme\Python23"
Directory C:\Programme\Python23 is NOT valid and will be removed from Path-Environment
Checking "C:\Programme\pstools"
Directory C:\Programme\pstools is NOT valid and will be removed from Path-Environment
Checking "%SystemRoot%\system32"
Directory %SystemRoot%\system32 is NOT valid and will be removed from Path-Environment
Checking "%SystemRoot%"
Directory %SystemRoot% is NOT valid and will be removed from Path-Environment
<output>
my script starts here:
print "Validating Path-Environment\n"; ReadPath(); # Subroutine that reads the PATH from registry # and returns $checkPath undef $/; @tempPath = split(/;/, $checkPath); foreach my $is (@tempPath) { print "Checking \"$is\"\n"; if ( -d "$is" ) { print "Directory $is is valid and will stay in Path-Environment\n"; }else{ print "Directory $is is NOT valid and will be removed\n"; } }
Is there a way to get %SystemRoot% translated _and_ get all entries in my Array?
Any help would be really appreciated!
Alex
smime.p7s
Description: S/MIME Cryptographic Signature