Hi Mark , All
I have written plenty of scripts involving directory traversals and -d \ -f
have never let me down.
One of my scripts runs daily on an NT machine.
The line I use for distinguishing between files and directories is :
$type = "f" unless ((-d "$lclpath\\$name")&&($type="d"));
The $lclpath is the current directory I have opened using opendir and $name
is the current directory entry I get using readdir().
Then we may continue as ...
if ($type eq "f")
{
....
}
else
{
.....
}
Check again and see if this helps...
-aman
-----Original Message-----
From: Mark Goland [mailto:mgoland@;optonline.net]
Sent: Friday, November 08, 2002 12:45 PM
To: perl
Subject: win32::File
Hi all,
I am trying to do directory traversal on NTFS. When I test fileif its a
directory or a regular file. It does not seem to work. -d anf -f test's dont
seem to work as well. Can someone please look over my error.
Thankx in advance, Mark
#!c:\perl\bin\perl -w
use Win32::File ;
&my_trav('.');
sub my_trav(){
$DIRNAME.=$_[0];
print "in dir $DIRNAME\n";
opendir DIR,$DIRNAME;
@dir=readdir DIR;
foreach $Val(@dir){
Win32::File::GetAttributes("$Val", $attr);
print "Direcotry:\t$Val\tattrib=$attr\n" if ( $attr & DIRECTORY);
print "File:\t$Val\tattrib=$attr\n" if ( $attr & NORMAL);
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]