1File::Which(3)        User Contributed Perl Documentation       File::Which(3)
2
3
4

NAME

6       File::Which - Portable implementation of the `which' utility
7

SYNOPSIS

9         use File::Which;                  # exports which()
10         use File::Which qw(which where);  # exports which() and where()
11
12         my $exe_path = which('perldoc');
13
14         my @paths = where('perl');
15         - Or -
16         my @paths = which('perl'); # an array forces search for all of them
17

DESCRIPTION

19       "File::Which" was created to be able to get the paths to executable
20       programs on systems under which the `which' program wasn't implemented
21       in the shell.
22
23       "File::Which" searches the directories of the user's "PATH" (as
24       returned by "File::Spec->path()"), looking for executable files having
25       the name specified as a parameter to "which()". Under Win32 systems,
26       which do not have a notion of directly executable files, but uses
27       special extensions such as ".exe" and ".bat" to identify them,
28       "File::Which" takes extra steps to assure that you will find the
29       correct file (so for example, you might be searching for "perl", it'll
30       try perl.exe, perl.bat, etc.)
31

Steps Used on Win32, DOS, OS2 and VMS

33   Windows NT
34       Windows NT has a special environment variable called "PATHEXT", which
35       is used by the shell to look for executable files. Usually, it will
36       contain a list in the form ".EXE;.BAT;.COM;.JS;.VBS" etc. If
37       "File::Which" finds such an environment variable, it parses the list
38       and uses it as the different extensions.
39
40   Windows 9x and other ancient Win/DOS/OS2
41       This set of operating systems don't have the "PATHEXT" variable, and
42       usually you will find executable files there with the extensions
43       ".exe", ".bat" and (less likely) ".com". "File::Which" uses this
44       hardcoded list if it's running under Win32 but does not find a
45       "PATHEXT" variable.
46
47   VMS
48       Same case as Windows 9x: uses ".exe" and ".com" (in that order).
49

Functions

51   which($short_exe_name)
52       Exported by default.
53
54       $short_exe_name is the name used in the shell to call the program (for
55       example, "perl").
56
57       If it finds an executable with the name you specified, "which()" will
58       return the absolute path leading to this executable (for example,
59       /usr/bin/perl or C:\Perl\Bin\perl.exe).
60
61       If it does not find the executable, it returns "undef".
62
63       If "which()" is called in list context, it will return all the matches.
64
65   where($short_exe_name)
66       Not exported by default.
67
68       Same as "which($short_exe_name)" in array context. Same as the `where'
69       utility, will return an array containing all the path names matching
70       $short_exe_name.
71

BUGS AND CAVEATS

73       Not tested on VMS or MacOS, although there is platform specific code
74       for those. Anyone who haves a second would be very kind to send me a
75       report of how it went.
76
77       File::Spec adds the current directory to the front of PATH if on Win32,
78       VMS or MacOS. I have no knowledge of those so don't know if the current
79       directory is searced first or not. Could someone please tell me?
80

SUPPORT

82       Bugs should be reported via the CPAN bug tracker at
83
84       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Which>
85
86       For other issues, contact the maintainer.
87

AUTHOR

89       Adam Kennedy <adamk@cpan.org>
90
91       Per Einar Ellefsen <pereinar@cpan.org>
92
93       Originated in modperl-2.0/lib/Apache/Build.pm. Changed for use in
94       DocSet (for the mod_perl site) and Win32-awareness by me, with slight
95       modifications by Stas Bekman, then extracted to create "File::Which".
96
97       Version 0.04 had some significant platform-related changes, taken from
98       the Perl Power Tools `which' implementation by Abigail with
99       enhancements from Peter Prymmer. See
100       <http://www.perl.com/language/ppt/src/which/index.html> for more
101       information.
102
104       Copyright 2002 Per Einar Ellefsen.
105
106       Some parts copyright 2009 Adam Kennedy.
107
108       This program is free software; you can redistribute it and/or modify it
109       under the same terms as Perl itself.
110

SEE ALSO

112       File::Spec, which(1), Perl Power Tools:
113       <http://www.perl.com/language/ppt/index.html>.
114
115
116
117perl v5.10.1                      2009-09-26                    File::Which(3)
Impressum