Add ARM files
[dh-make-perl] / dev / arm / libfile-which-perl / libfile-which-perl-0.05 / debian / tmp / usr / bin / pwhich
1 #!/usr/bin/perl -w
2
3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4     if 0; # not running under some shell
5
6 use strict;
7
8 use File::Which;
9 use Getopt::Std;
10
11 my %opts = ();
12
13 getopts('av', \%opts);
14
15 my @files = @ARGV;
16
17 if ($opts{v}) {
18     print <<"END";
19 This is pwhich running File::Which version $File::Which::VERSION
20
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.
24 END
25
26     exit;
27 }
28
29 unless(@files) {
30     print <<"EOS";
31 Usage: $0 [-a] [-v] programname [programname ...]
32       -a        Print all matches in PATH, not just the first.
33       -v        Prints version and exits
34
35 EOS
36           
37     exit;
38 }
39
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;
45     }
46     print STDERR "pwhich: no $file in PATH\n" unless @result;
47 }
48
49 __END__
50
51 =head1 NAME
52
53 pwhich - Perl-only `which'
54
55 =head1 Synopsis
56
57   $ pwhich perl
58   $ pwhich -a perl          # print all matches
59   $ pwhich perl perldoc ... # look for multiple programs
60   $ pwhich -a perl perldoc ...
61
62 =head1 DESCRIPTION
63
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.
68
69
70 =head1 Calling syntax
71
72   $ pwhich [-a] [-v] programname [programname ...]
73
74 =head2 Options
75
76 =over
77
78 =item -a
79
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
82 on a separate line.
83
84 =item -v
85
86 Prints version (of C<File::Which>) and copyright notice and exits.
87
88 =back
89
90 =head1 License
91
92 This program is free software; you can redistribute it and/or modify
93 it under the same terms as Perl itself.
94
95 =head1 See Also
96
97 L<perl>, L<File::Which>, L<which(1)>
98
99 =head1 Author
100
101 Per Einar Ellefsen, E<lt>per.einar (at) skynet.beE<gt>
102
103 =cut
104