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(), ), );

                - tye

In reply to Re: Using File::Find to find drive (Win32) (how) by tye
in thread Using File::Find to find drive (Win32) by FireBird34

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.