in reply to Searching directories

One advise, use the IO::Dir module from CPAN, that's the future of Perl.
use IO::Dir; $root = "D:\"; $dir = new IO::Dir $root or die "Can not list directory"; while( $_ = $dir->read ) { print "Directory: $root\\$_\n" if (-d "$root\\$_"); }

Replies are listed 'Best First'.
Re: Re: Searching directories
by softworkz (Monk) on Sep 23, 2003 at 16:08 UTC
    How about this way, tested on windoze 2000/Xp
    use strict; use File::Find; use Win32::File; use Cwd; my $dir = cwd; my $attr; my $output ="dump.txt"; open(OUTPUT,">$output") || die "can't open $output: $!"; &File::Find::find(\&wanted,"$dir"); sub wanted{ print OUTPUT "Directory $_ \n" if(-d $_); -f $_ && (Win32::File::GetAttributes($_, $attr)) && print OUTPUT "File +\t\ $_\n"; } close(OUTPUT);
      Ah... but this approach took away the portability of the code with the use of the Win32 module. Unless of course you only want the script to run on a Windows box.