[EMAIL PROTECTED] <> wrote:
> 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"; } 

That's how you refer to environment variables on the win32 command line,
etc. It means nothing to Perl. I suspect that it is unlikely that you
have a sub-directory of the current working directory named
"%systemdrive%". However, Perl has a special hash called %ENV for
environment variables. You should use that, e.g;

if(-e "$ENV{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"; }  

The above doesn't do what you think it does, it only appears to work by
coincidence. Try printing the contents of $sysdir and $file. You will
see that you are testing the existence of a file called
"\\servicedisk\\tools\\seachange\\SeaPatch.exe".

HTH

-- 
Brian Raven 


=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


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

Reply via email to