10 getopts('av', \%opts);
16 This is pwhich running File::Which version $File::Which::VERSION
18 Copyright 2002 Per Einar Ellefsen.
19 This program is free software; you can redistribute it and/or modify
20 it under the same terms as Perl itself.
28 Usage: $0 [-a] [-v] programname [programname ...]
29 -a Print all matches in PATH, not just the first.
30 -v Prints version and exits
37 for my $file (@files) {
38 my @result = $opts{a} ? which($file) : scalar which($file); # need to force scalar
39 @result = () unless defined $result[0]; # we might end up with @result = (undef) -> 1 elem
40 for my $result (@result) {
41 print "$result\n" if $result;
43 print STDERR "pwhich: no $file in PATH\n" unless @result;
50 pwhich - Perl-only `which'
55 $ pwhich -a perl # print all matches
56 $ pwhich perl perldoc ... # look for multiple programs
57 $ pwhich -a perl perldoc ...
61 `pwhich' is a command-line utility program for finding paths to other
62 programs based on the user's C<PATH>. It is similar to the usualy Unix
63 tool `which', and tries to emulate its functionality, but is written
64 purely in Perl (uses the module C<File::Which>), so is portable.
69 $ pwhich [-a] [-v] programname [programname ...]
77 The option I<-a> will make C<pwhich> print all matches found in the
78 C<PATH> variable instead of just the first one. Each match is printed
83 Prints version (of C<File::Which>) and copyright notice and exits.
89 This program is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.
94 L<perl>, L<File::Which>, L<which(1)>
98 Per Einar Ellefsen, E<lt>per.einar (at) skynet.beE<gt>