
shawnhcorey
Enthusiast

Sep 30, 2008, 3:21 PM
Post #3 of 5
(423 views)
|
|
Re: [Newton] -d, -f directory, file checking problem
[In reply to]
|
Can't Post
|
|
Hi, I am attempting to batch access the contents of a group of directories (within a parent directory) but am having trouble getting the -d directory testing flag to work. A snippet of my code follows: opendir(DIR,$DirName); while(my $SubDir = readdir(DIR)) { next if $SubDir =~ /^\./; if (-d $SubDir) { ... work on contents of sub-directory } } The problem is that my subdirectories in DIR are not being seen as directories and I can't go on. I have specified a full path to $DirName and the -d test still doesn't work. Thanks in advance for any help, N. You specified the full path for $DirName but not $SubDir.opendir(DIR,$DirName); while(my $SubDir = readdir(DIR)) { next if $SubDir =~ /^\./; if (-d "$DirName/$SubDir") { ... work on contents of sub-directory } } __END__ I love Perl; it's the only language where you can bless your thingy. Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib. Get Markup Help. Please note the markup tag of "code".
|