----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, June 08, 2006 11:58 AM
Subject: attempting to understand an unexpected response from existence
testing
Hi again Gurus!
I am trying to expand my understanding of perl. i do not understand why
the first test fails and the latter two succeed. shouldn't the first
succeed as well?
-Josh
code:
#!/usr/bin/perl
use strict;
# 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"; }
Not sure by what you mean it does not work
On my system, the response is "no" in each case since my drive does not
contain the specified file
now if you have a statement such as "print "%system" -> %system% ... which
means that %system% is not interpolated. it is taken literally and no such
relative path exist. Perl does not know that %system% is a symbol for an
environmental variable
now if you print out the value $sysdir after executing $sysdir = `%system%`,
you will find that it is an empty string. You can type %system% in a does
window and there will be no response of any kind.
this means that the path is an absolute path starting at the root of the
drive you are executing the script, which apparently is your system drive.
Effectively your path begins with "\" which is the root or absolute path
to catch the environmental value of %system% you need to $sysdir = `echo
%system%` and then you will get "C:" (at least on my system)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs