|
I m reading all files and directory in a given directory using the below code but when I m trying to test wethere $file ( in below code ) is a file or dir it is not happening. Can u please tell me the error.
opendir DIR, 'C:/Perl/eg/test/test' || die "could not open the current directory: $!" ;
while (my $file = readdir(DIR) ) {
if ($file eq "." or $file eq ".." or $file eq "/forum/readdir.html" ) {
print "oops not a log file\n";
}
else {
if (-d $file) { print "dir\n";
}
if (-f $file) { print "file\n";
}
print "$file\n";
}
}
closedir(DIR);
In the ab
|
|
|
$dir = "d:/mp3"; Directory do u want
#use Cwd; If you want go to local file folder
#$dir = cwd;
chdir $dir;
opendir(DIR, $dir) or die "can't opendir $dirname1: $!";
while (defined($file5 = readdir(DIR))) {
print $file5 . "\n";
};
closedir(DIR);
|
|
|
|
|
|
|
|
|
// |