File::Find directory conundrum 
Author Message
 File::Find directory conundrum

Thanks Helgi for your answer (below) I'm about to try what you suggested.

I have a similar problem.
I'm counting directories in a directory and each directory below that.

A simple question.
How do I know if the current $_ is a directory or a file??

I've been using  if ($_ !~ /\./) # if no dots in the filename
This is fine until I come across a filename such as README or similar.

Is their a sure fire way I can know if the current $_ is definitely a
directory?

RD



Tue, 05 Apr 2005 16:53:02 GMT  
 File::Find directory conundrum

Quote:

> How do I know if the current $_ is a directory or a file??

   print "$_ is a directory if -d;

For more info:

   perldoc -f -d

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Tue, 05 Apr 2005 18:32:39 GMT  
 File::Find directory conundrum

{*filter*}> Is their a sure fire way I can know if the current $_ is definitely a
{*filter*}> directory?

  if (-d $_) { "it's a directory!" }

print "Just another Perl hacker,"

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Tue, 05 Apr 2005 18:50:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. File::Find with Compressed NTFS directories

2. Deleting empty sub directories with File::Find

3. Get directory only once and put it in array with File::Find

4. File::Find: how to exclude directories?

5. finding the newest file in a directory

6. Finding the last-newest file in a directory

7. stat can't find file or directory

8. File::Find without desending into sub directories

9. File::Find with compressed NTFS directories

10. Use File:Find not in current directory

11. finding a file in a directory and reading it

12. finding a file in a directory??

 

 
Powered by phpBB® Forum Software