package Psh
::Builtins
::Which
;
Locates the command in the filesystem.
=item * C<which -m module>
Locates the perl module in the filesystem
=item * C<which -r module>
Locates a command using a Perl regexp
Option C<-a> may be used to see more than one match.
Option C<-v> switches to a more verbose output.
$inpod = /^=(?!cut)/ ?
1: /^=cut/ ?
0 : $inpod;
next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
$result = 'undef' unless defined $result;
local @ARGV = @
{shift()};
Getopt
::Std
::getopts
('aprmv',$opt);
my $rest= join(' ',@ARGV);
if ($opt->{'m'}) { # perl module search
$rest=~ s/::/$Psh::OS::FILE_SEPARATOR/g;
foreach my $dir (@Psh::origINC
) {
my $file= Psh
::OS
::catfile
($dir,$rest.'.pm');
Psh
::Util
::print_out
($file);
my $version= parse_version
($file);
Psh
::Util
::print_out
(" $version");
Psh
::Util
::print_out
("\n");
return (1,undef) if $foundsth;
Psh
::Util
::recalc_absed_path
();
foreach my $dir (@Psh::absed_path
) {
while (my $tmp= readdir(DIR
)) {
next unless $tmp=~/$rest/;
$tmp= Psh
::OS
::catfile
($dir,$tmp);
Psh
::Util
::print_out
("$tmp\n");
last if $foundsth and !$opt->{a
};
return (1,undef) if $foundsth;
push @tmp, Psh
::Util
::which
($rest,$opt->{'a'}?
1:0);
Psh
::Util
::print_out
("$_\n");
return (1,undef) if @tmp;