[EMAIL PROTECTED] wrote at Thu, 08 Jun 2006 11:58:21 -0400:

# doesn't work
if(-e "%systemdrive%\\servicedisk\\tools\\seachange\\SeaPatch.exe"){ print "yes\n"; }else{ print "no\n"; }

# work on either versions

my $sysdir=`%systemdrive%`;
my $file ="$sysdir\\servicedisk\\tools\\seachange\\SeaPatch.exe";
if(-e $file){ print "yes\n"; }else{ print "no\n"; }
if(-e "$sysdir\\servicedisk\\tools\\seachange\\SeaPatch.exe"){ print "yes\n"; }else{ print "no\n"; }

%systemdrive% (and any other environment variable delimited by %) doesn't mean anything inside Perl, it only works in Windows and its command shell. It works in the second example because you're enclosing it in backticks, which passes it to the shell.

You want to use the %ENV hash anyway, which contains environment variables regardless of platform. So use $ENV{'systemdrive'} and you'll be fine.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to