Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

(ichi) Re: File::Find

by ichimunki (Priest)
on Jun 07, 2002 at 18:18 UTC ( #172602=note: print w/replies, xml ) Need Help??

in reply to File::Find

CPAN is your friend here. You want the Win32::DriveInfo module. Otherwise the root ('/' not '../', btw) of each drive volume is separate: C:, D:, etc. (enclosed sample code untested)
use File::Find; use Win32::DriveInfo; for( Win32::DriveInfo::DrivesInUse ) { find( \&handleFind, "$_:" ); } sub handleFind {... same as before ...}
UPDATE: Correct error in use of drive letter ':' is required

Note: installing Win32::DriveInfo requires installing Win32::API. The former is available only from CPAN, the latter is available as a PPM. Fortunately Win32::Drive info is pure Perl and can simply be copied to C:/perl/lib/site/lib/win32 and used from there.

Replies are listed 'Best First'.
Re: (ichi) Re: File::Find
by Util (Priest) on Jun 10, 2002 at 03:16 UTC
    I agree, Win32::DriveInfo is best.
    As we just discussed here, this code also works:
    use File::Find; use Win32API::File qw( :Func :DRIVE_ ); my @drives = map { tr{\\}{/}s; $_ } grep { GetDriveType($_) == DRIVE_FIXED } getLogicalDrives(); find( sub { $File::Find::prune = 1, return if $File::Find::name =~ m{^.:/System Volume Information$}; print "$_\n"; }, @drives );
    Perhaps someone will find it useful when Win32API::File is at hand, but Win32::DriveInfo is not.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://172602]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2018-03-19 02:17 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.