.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "File::Which 3"
.TH File::Which 3 "2017-09-08" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
File::Which \- Perl implementation of the which utility as an API
.SH "VERSION"
.IX Header "VERSION"
version 1.22
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& use File::Which;                  # exports which()
\& use File::Which qw(which where);  # exports which() and where()
\& 
\& my $exe_path = which \*(Aqperldoc\*(Aq;
\& 
\& my @paths = where \*(Aqperl\*(Aq;
\& # Or
\& my @paths = which \*(Aqperl\*(Aq; # an array forces search for all of them
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
File::Which finds the full or relative paths to executable programs on
the system.  This is normally the function of \f(CW\*(C`which\*(C'\fR utility.  \f(CW\*(C`which\*(C'\fR is
typically implemented as either a program or a built in shell command.  On
some platforms, such as Microsoft Windows it is not provided as part of the
core operating system.  This module provides a consistent \s-1API\s0 to this
functionality regardless of the underlying platform.
.PP
The focus of this module is correctness and portability.  As a consequence
platforms where the current directory is implicitly part of the search path
such as Microsoft Windows will find executables in the current directory,
whereas on platforms such as \s-1UNIX\s0 where this is not the case executables 
in the current directory will only be found if the current directory is
explicitly added to the path.
.PP
If you need a portable \f(CW\*(C`which\*(C'\fR on the command line in an environment that
does not provide it, install App::pwhich which provides a command line
interface to this \s-1API.\s0
.SS "Implementations"
.IX Subsection "Implementations"
File::Which searches the directories of the user's \f(CW\*(C`PATH\*(C'\fR (the current
implementation uses File::Spec#path to determine the correct \f(CW\*(C`PATH\*(C'\fR),
looking for executable files having the name specified as a parameter to
\&\*(L"which\*(R". Under Win32 systems, which do not have a notion of directly
executable files, but uses special extensions such as \f(CW\*(C`.exe\*(C'\fR and \f(CW\*(C`.bat\*(C'\fR
to identify them, \f(CW\*(C`File::Which\*(C'\fR takes extra steps to assure that
you will find the correct file (so for example, you might be searching for
\&\f(CW\*(C`perl\*(C'\fR, it'll try \fIperl.exe\fR, \fIperl.bat\fR, etc.)
.PP
\fILinux, *BSD and other UNIXes\fR
.IX Subsection "Linux, *BSD and other UNIXes"
.PP
There should not be any surprises here.  The current directory will not be
searched unless it is explicitly added to the path.
.PP
\fIModern Windows (including \s-1NT, XP,\s0 Vista, 7, 8, 10 etc)\fR
.IX Subsection "Modern Windows (including NT, XP, Vista, 7, 8, 10 etc)"
.PP
Windows \s-1NT\s0 has a special environment variable called \f(CW\*(C`PATHEXT\*(C'\fR, which is used
by the shell to look for executable files. Usually, it will contain a list in
the form \f(CW\*(C`.EXE;.BAT;.COM;.JS;.VBS\*(C'\fR etc. If \f(CW\*(C`File::Which\*(C'\fR finds such an
environment variable, it parses the list and uses it as the different
extensions.
.PP
\fICygwin\fR
.IX Subsection "Cygwin"
.PP
Cygwin provides a Unix-like environment for Microsoft Windows users.  In most
ways it works like other Unix and Unix-like environments, but in a few key
aspects it works like Windows.  As with other Unix environments, the current
directory is not included in the search unless it is explicitly included in
the search path.  Like on Windows, files with \f(CW\*(C`.EXE\*(C'\fR or <.BAT> extensions will
be discovered even if they are not part of the query.  \f(CW\*(C`.COM\*(C'\fR or extensions
specified using the \f(CW\*(C`PATHEXT\*(C'\fR environment variable will \s-1NOT\s0 be discovered
without the fully qualified name, however.
.PP
\fIWindows 95, 98, \s-1ME,\s0 MS-DOS, \s-1OS/2\s0\fR
.IX Subsection "Windows 95, 98, ME, MS-DOS, OS/2"
.PP
This set of operating systems don't have the \f(CW\*(C`PATHEXT\*(C'\fR variable, and usually
you will find executable files there with the extensions \f(CW\*(C`.exe\*(C'\fR, \f(CW\*(C`.bat\*(C'\fR and
(less likely) \f(CW\*(C`.com\*(C'\fR. \f(CW\*(C`File::Which\*(C'\fR uses this hardcoded list if it's running
under Win32 but does not find a \f(CW\*(C`PATHEXT\*(C'\fR variable.
.PP
As of 2015 none of these platforms are tested frequently (or perhaps ever),
but the current maintainer is determined not to intentionally remove support
for older operating systems.
.PP
\fI\s-1VMS\s0\fR
.IX Subsection "VMS"
.PP
Same case as Windows 9x: uses \f(CW\*(C`.exe\*(C'\fR and \f(CW\*(C`.com\*(C'\fR (in that order).
.PP
As of 2015 the current maintainer does not test on \s-1VMS,\s0 and is in fact not
certain it has ever been tested on \s-1VMS.\s0  If this platform is important to you
and you can help me verify and or support it on that platform please contact
me.
.SH "FUNCTIONS"
.IX Header "FUNCTIONS"
.SS "which"
.IX Subsection "which"
.Vb 2
\& my $path = which $short_exe_name;
\& my @paths = which $short_exe_name;
.Ve
.PP
Exported by default.
.PP
\&\f(CW$short_exe_name\fR is the name used in the shell to call the program (for
example, \f(CW\*(C`perl\*(C'\fR).
.PP
If it finds an executable with the name you specified, \f(CW\*(C`which()\*(C'\fR will return
the absolute path leading to this executable (for example, \fI/usr/bin/perl\fR or
\&\fIC:\ePerl\eBin\eperl.exe\fR).
.PP
If it does \fInot\fR find the executable, it returns \f(CW\*(C`undef\*(C'\fR.
.PP
If \f(CW\*(C`which()\*(C'\fR is called in list context, it will return \fIall\fR the
matches.
.SS "where"
.IX Subsection "where"
.Vb 1
\& my @paths = where $short_exe_name;
.Ve
.PP
Not exported by default.
.PP
Same as \*(L"which\*(R" in array context. Same as the
\&\f(CW\*(C`where\*(C'\fR utility, will return an array containing all the path names
matching \f(CW$short_exe_name\fR.
.SH "CAVEATS"
.IX Header "CAVEATS"
This module has no non-core requirements for Perl 5.6.2 and better.
.PP
This module is fully supported back to Perl 5.8.1.  It may work on 5.8.0.  
It should work on Perl 5.6.x and I may even test on 5.6.2.  I will accept
patches to maintain compatibility for such older Perls, but you may
need to fix it on 5.6.x / 5.8.0 and send me a patch.
.PP
Not tested on \s-1VMS\s0 although there is platform specific code
for those. Anyone who haves a second would be very kind to send me a
report of how it went.
.SH "SUPPORT"
.IX Header "SUPPORT"
Bugs should be reported via the GitHub issue tracker
.PP
<https://github.com/plicease/File\-Which/issues>
.PP
For other issues, contact the maintainer.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
.IP "pwhich, App::pwhich" 4
.IX Item "pwhich, App::pwhich"
Command line interface to this module.
.IP "IPC::Cmd" 4
.IX Item "IPC::Cmd"
Comes with a \f(CW\*(C`can_run\*(C'\fR function with slightly different semantics that
the traditional \s-1UNIX\s0 where.  It will find executables in the current
directory, even though the current directory is not searched for by
default on Unix.
.IP "Devel::CheckBin" 4
.IX Item "Devel::CheckBin"
This module purports to \*(L"check that a command is available\*(R", but does not
provide any documentation on how you might use it.
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
Per Einar Ellefsen <pereinar@cpan.org>
.IP "\(bu" 4
Adam Kennedy <adamk@cpan.org>
.IP "\(bu" 4
Graham Ollis <plicease@cpan.org>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2002 by Per Einar Ellefsen <pereinar@cpan.org>.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
