Try this:
open INF, "c:\\system.txt" || die "Unable to open file $!\n";
@file_txt = <INF>;
close(INF);
foreach $val (@file_txt) {
chomp($val);
$val=~s#\\#/#gi; # replace '\' with '/'
($exist)=stat($val);
if ($exist) {
print "$val - exists\n";
}
}
You missed the OPEN line... you must double the backslash... and always
check for "is the file open??"
The only other change I made was putting a newline on your output. You might
be able to do an 'exist' check with just "-e"... but using stat works.
Charles Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 942-2726
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf
Of Roee Rubin
Sent: Tuesday, May 16, 2000 12:28 PM
To: Perl-Win32-Users Mailing List
Subject: Verify file exists
Hello,
I am trying to verify if a file exists on a network drive
(\\drive\volume\etc).
The name of the files I am trying to verify are located in a text file, and
are written in the above format.
The following code does not seem to work ...
open (INF, "system.txt"); #read file
@file_txt=<INF>;
close(INF);
foreach $val (@file_txt) {
chomp($val);
$val=~s#\\#/#gi; # replace '\' with '/'
($exist)=stat($val);
if ($exist) {
print "$val - exists";
}
}
your help is appreciated .
Roee Rubin
[EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [EMAIL PROTECTED]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]