Newbee21369
Programmer
I'm trying to read only files in a directory. I have tried the code below but still having issues. Any suggestions?
#### Need to keep this code unchanged
opendir DIR, "Whatever/path";
@files=grep { !/^\.+$/ } readdir(DIR);
closedir DIR;
####Need to return only files in code shown below. I have tried -f $file, !-d $file, -e$file in my if condition and it is still returning Files and directories.
foreach $file (@files)
{
if (-f $file)
{
#print whatever
}
}
#### Need to keep this code unchanged
opendir DIR, "Whatever/path";
@files=grep { !/^\.+$/ } readdir(DIR);
closedir DIR;
####Need to return only files in code shown below. I have tried -f $file, !-d $file, -e$file in my if condition and it is still returning Files and directories.
foreach $file (@files)
{
if (-f $file)
{
#print whatever
}
}