in reply to Using File::Find to find drive (Win32)
If you just want to find the location of the Perl.exe that is being run, then ( in Windows, unlike in some, inferior operating systems like Unix :) just check $^X which will always contain the full path to the Perl.exe that is being used.
(Update: Note that the above method is very reliable, not relying on somewhat optional aspects of the Perl installation. It uses a feature built directly into the Perl executable and a feature built into the Windows operating system. For example, you can move your Perl installation and it will work quite nicely (so long as Perl.exe can be found) for almost all tasks even if you didn't update Config.pm with the new locations. Or you could have a distribution of Perl not from ActiveState or have two versions installed and not be using the one recorded in the registry.)
(Update: However, it does rely on you not having crippled your "Windows Perl" by actually using Cygwin Perl, as idsfa notes.)
[Update: If you want to get the root directory of the Perl installation, you can use File::Basename's basename() twice on $^X. If you just want the drive letter, then you can even use the first value returned by File::Spec's splitpath().]
If you want to search for something named "Perl" that might not be related to the instance of Perl that you are using, then you can use File::Find or other modules and pass it a list of disk drives from Win32API::File:
use Win32API::File qw( getLogicalDrives GetDriveType DRIVE_FIXED ); use File::Find qw( find ); find( sub { print $File::Find::name,$/ if "perl" eq lc($_); }, grep( DRIVE_FIXED == GetDriveType($_), getLogicalDrives(), ), );
|
|---|