3 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
11 use vars qw{$VERSION};
18 Getopt::Std::getopts('av', \%opts);
22 This is pwhich running File::Which version $File::Which::VERSION
24 Copyright 2002 Per Einar Ellefsen.
26 Some parts copyright 2009 Adam Kennedy.
28 This program is free software; you can redistribute it and/or modify
29 it under the same terms as Perl itself.
37 Usage: $0 [-a] [-v] programname [programname ...]
38 -a Print all matches in PATH, not just the first.
39 -v Prints version and exits
46 foreach my $file ( @ARGV ) {
48 ? File::Which::which($file)
49 # Need to force scalar
50 : scalar File::Which::which($file);
52 # We might end up with @result = (undef) -> 1 elem
53 @result = () unless defined $result[0];
54 foreach my $result ( @result ) {
55 print "$result\n" if $result;
58 print STDERR "pwhich: no $file in PATH\n";
71 pwhich - Perl-only `which'
76 $ pwhich -a perl # print all matches
77 $ pwhich perl perldoc ... # look for multiple programs
78 $ pwhich -a perl perldoc ...
82 `pwhich' is a command-line utility program for finding paths to other
83 programs based on the user's C<PATH>. It is similar to the usualy Unix
84 tool `which', and tries to emulate its functionality, but is written
85 purely in Perl (uses the module C<File::Which>), so is portable.
89 $ pwhich [-a] [-v] programname [programname ...]
97 The option I<-a> will make C<pwhich> print all matches found in the
98 C<PATH> variable instead of just the first one. Each match is printed
103 Prints version (of C<File::Which>) and copyright notice and exits.
109 Bugs should be reported via the CPAN bug tracker at
111 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Which>
113 For other issues, contact the maintainer.
117 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
119 Per Einar Ellefsen E<lt>pereinar@cpan.orgE<gt>
121 Originated in F<modperl-2.0/lib/Apache/Build.pm>. Changed for use in DocSet
122 (for the mod_perl site) and Win32-awareness by me, with slight modifications
123 by Stas Bekman, then extracted to create C<File::Which>.
125 Version 0.04 had some significant platform-related changes, taken from
126 the Perl Power Tools C<`which'> implementation by Abigail with
127 enhancements from Peter Prymmer. See
128 L<http://www.perl.com/language/ppt/src/which/index.html> for more
133 Copyright 2002 Per Einar Ellefsen.
135 Some parts copyright 2009 Adam Kennedy.
137 This program is free software; you can redistribute it and/or modify
138 it under the same terms as Perl itself.
142 L<perl>, L<File::Which>, L<which(1)>