in reply to Using File::Find to find drive (Win32)
which produces a nice list of drive root directories, with a trailing backslash. Nice.use Win32::API; my $GetLogicalDriveStrings = new Win32::API(kernel32 => GetLogicalDriv +eStrings => ['N', 'P'], 'N'); my $drives = "\0" x 4000; my @drives; if($GetLogicalDriveStrings->Call(length $drives, $drives)) { @drives = split /\0+/, $drives; }
You might want to skip the floppies, though... 'A:' and 'B:'. There's an API call to recognize ejectable drives, but I'll skip that for now.
Now we have a list of roots to scan into, we still have to actually do it:
The result of everything found is in a hash. The directory itself will be the hash key, the files found will be in the array that is the hash value.use File::Find; my %results; find sub { -f and push @{$results{$File::Find::dir}}, $_ if -e && /^pe +rl/ }, @drives; use Data::Dumper; print Dumper \%results;
update: warning: this takes ages for me to do its job. Don't use it on a regular basis. :)
|
|---|