[EMAIL PROTECTED] wrote:
> 
> I was thinking that the test would work because it would query the
> environment. What i was missing is that it skips that for testing
> existence.

No, Perl never queries the environment unless you specifically tell it
to.

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

Here, "%systemdrive" is being treated as a Perl hash and probably
expands to a null string.

> > # 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"; }

Here, you are explicitly opening a shell to get the environment
variable.

As others have mentioned, this will work better (and is preferred):

    my $sysdir = $ENV{systemdrive};

Also, Perl's file handling is quite capable of using forward slashes
in paths.  You can make things much more readable that way.

For example:
    "$sysdir/servicedisk/tools/seachange/SeaPatch.exe"

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

Reply via email to