3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
13 getopts('av', \%opts);
19 This is pwhich running File::Which version $File::Which::VERSION
21 Copyright 2002 Per Einar Ellefsen.
22 This program is free software; you can redistribute it and/or modify
23 it under the same terms as Perl itself.
31 Usage: $0 [-a] [-v] programname [programname ...]
32 -a Print all matches in PATH, not just the first.
33 -v Prints version and exits
40 for my $file (@files) {
41 my @result = $opts{a} ? which($file) : scalar which($file); # need to force scalar
42 @result = () unless defined $result[0]; # we might end up with @result = (undef) -> 1 elem
43 for my $result (@result) {
44 print "$result\n" if $result;
46 print STDERR "pwhich: no $file in PATH\n" unless @result;
53 pwhich - Perl-only `which'
58 $ pwhich -a perl # print all matches
59 $ pwhich perl perldoc ... # look for multiple programs
60 $ pwhich -a perl perldoc ...
64 `pwhich' is a command-line utility program for finding paths to other
65 programs based on the user's C<PATH>. It is similar to the usualy Unix
66 tool `which', and tries to emulate its functionality, but is written
67 purely in Perl (uses the module C<File::Which>), so is portable.
72 $ pwhich [-a] [-v] programname [programname ...]
80 The option I<-a> will make C<pwhich> print all matches found in the
81 C<PATH> variable instead of just the first one. Each match is printed
86 Prints version (of C<File::Which>) and copyright notice and exits.
92 This program is free software; you can redistribute it and/or modify
93 it under the same terms as Perl itself.
97 L<perl>, L<File::Which>, L<which(1)>
101 Per Einar Ellefsen, E<lt>per.einar (at) skynet.beE<gt>