Perl file test operator help
- by Aaron Moodie
This is a really basic issue, but I'm new to perl and cannot work out what the issue is. I'm just trying to isolate the files in a directory, but the -d operator keeps treating all the folder contents as files ...
@contents is my array, and when I run this:
foreach $item(@contents) {
if (-d $item) { next; }
print"$item is a file\n";
}
I keep getting both folders and files. Alternatively, if I use -f, I get nothing.
edit: this is the output -
file01.txt is a file
folder 01 is a file
folder 02 is a file
Screen shot 2010-04-18 at 1.26.17 PM.png is a file
I'm running this on OSX