Hi,
I have this snippet of code in which I am trying to print out all the directories. It does not work using the -d, but -f does print all the files. Why doesn't -d work for directories? What am I doing wrong? This should be a pretty basic question for an experienced Perl programmer.
<code>
use strict;
use File::Find;
sub wanted
{
if (-d $File::Find::name)
{
print "$File::Find::name\n";
}
}
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
use File::Find;
sub wanted
{
print "$File::Find::name\n" if -d;
}
find(\&wanted, 'C:/');