rab54
asked on
How to find if a file exists on windows .... ?
Hi gurus -
OK I am using File::Find to check a directory for files - but I want to give an error if there are no files there -
The problem is I get $file = . - regardless of whether there is a file there or not !
I have tried using -e ...
any ideas guys ??
cheers
Rab
OK I am using File::Find to check a directory for files - but I want to give an error if there are no files there -
The problem is I get $file = . - regardless of whether there is a file there or not !
I have tried using -e ...
any ideas guys ??
cheers
Rab
Is that perl?
If so, is it a requirement that the solution be in perl?
If so, is it a requirement that the solution be in perl?
ASKER
The link above isn't in perl - but it is perl that I need ....
Anyway after further investigation - the problem is differentiating between the CWD (eg '.' ) and actual filenames -
If I loop thro all the files I get
.
..
test.txt
I need to say if it is '.' or '..' (without quotes ;~) - then give me a error message -
I have tried reg exes and also code like -
if (($file ne ".") || ($files ne "..") - blah
But none of it seems to work ....
any ideas would be great .....
cheers
rab
Anyway after further investigation - the problem is differentiating between the CWD (eg '.' ) and actual filenames -
If I loop thro all the files I get
.
..
test.txt
I need to say if it is '.' or '..' (without quotes ;~) - then give me a error message -
I have tried reg exes and also code like -
if (($file ne ".") || ($files ne "..") - blah
But none of it seems to work ....
any ideas would be great .....
cheers
rab
ASKER
OK Sorted -
As . and .. are always present - it means if the count is < 3 there is no file !
cheers all
rab
As . and .. are always present - it means if the count is < 3 there is no file !
cheers all
rab
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use this link for more info:
http://www.codeguru.com/forum/showthread.php?t=312458