Also, if you don't know how big system.txt is
gonna be, you might want to recode like this:
open(INF, "system.txt) || die "Could not open system.txt: $!\n";
while ($val = <INF>) {
...
}
close(INF);
That way you aren't sucking the entire contents
of a file into memory for no good reason...
Things also become a little more readable if you
take advantage of the default operand $_:
while (<INF>) {
chomp;
s|\\|/|g; # use | instead of # because # is for comments
print "$_ - exists\n" if (-e $_);
}
-Peter
---
Peter A. Vogel
Manager, Engineering Operations
iReady Corporation
http://www.iready.com; http://www.iready.net
> -----Original Message-----
> From: Roee Rubin [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 16, 2000 9:28 AM
> 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]
>