-----Original Message-----
From: Roee Rubin
Sent: Tuesday, May 16, 2000 10:53 AM
To: 'Martin Moss'
Subject: RE: Verify file exists
Still no go.
system.txt contents:
========
\\m1\vol\1\test.txt
================
open (INF, "system.txt"); #read file
@file_txt=<INF>;
close(INF);
foreach $val (@file_txt) {
chomp($val);
$val=~s|\\|\/|gi;
if (-e "$val") {
print "exist - $val\n";
}
else {
print "DNE - $val\n";
}
}
It prints DNE - //m1/vol/1/test.txt
-----Original Message-----
From: Martin Moss [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 16, 2000 10:38 AM
To: Roee Rubin
Subject: Re: Verify file exists
----- Original Message -----
From: "Roee Rubin" <[EMAIL PROTECTED]>
To: "Perl-Win32-Users Mailing List"
<[EMAIL PROTECTED]>
Sent: Tuesday, May 16, 2000 6:03 PM
Subject: RE: Verify file exists
> I think I am having problems with reading the text file and then
processing
> the actual path ...
>
> The following is the content of the file
>
> system.txt
> ===========
>
> \\m1\main\testing\file.txt <file://\\m1\main\testing\file.txt>
> \\m1\main\testing\file1.txt <file://\\m1\main\testing\file1.txt>
>
> if I replace the '\' character to '/' using s|\\|/|gi the file is never
> found.
>
> If I manually type in the file and then replace then the file is existent:
>
> $val="\\\\m1\\main\\testing\\file.txt"
> $val=~s|\\|/|gi; #You need to escape the '/' too!!!
>
Here's your problem.
Try printing out to your screen what name of the file is it's trying to
open.
You may find you're trying to open a file called
'//m1/main/testing/file.txt'
you should perhaps replacee '\\' with '\' before switching over to '/'
i.e.
$val=~s|\\\\|\/|gi;
$val=~s|\\|\/|gi
Marty
> if (-e "$val")
> {
> print "File exists\n";
> }
> else
> {
> print "file doesn't exist\n";
> }
>
> Any more thoughts on the issue would be welcome.
>
> Thanks
>
>
>
>
> -----Original Message-----
> From: Peter Vogel [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 16, 2000 9:59 AM
> To: Roee Rubin; Perl-Win32-Users Mailing List
> Subject: RE: Verify file exists
>
>
>
> 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.com;> http://www.iready.net
> <http://www.iready.net>
>
>
> > -----Original Message-----
> > From: Roee Rubin [ mailto:[EMAIL PROTECTED] <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]
> >
>
>
---
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]