> > >To determine the correct path for your perl interpretor, use:
> >
> > > which perl
> >
> > >--
> >
> > Please give me a context.
> >
>
> Note that the original post pertained to a Unix-like system
> (not Windows) -
> and the answer you've quoted above pertains primarily to
> Unix-like systems.
>
> On Unix -like systems if you were to enter 'which perl' at
> the command line,
> then the fully qualified path to the perl executable would be
> returned.
>
> On windows the same command could successfully be run in the
> msys shell, or
> in Cygwin's bash shell - and perhaps some other shells, too -
> but not the
> cmd.exe shell, unless you've installed a which.exe such as
> that available
> from http://gnuwin32.sourceforge.net/packages.html (as I have done):
>
Here's a perl version of 'which'. But it looks not only in $ENV{PATH} but also in @INC directories. I also created a which.bat file which calls which.pl because I am THAT lazy ;-)
###
use Cwd;
@_ = @ARGV;
my $cwd = getcwd unless $cwd = $ENV{'PWD'};
my $inc = join(";", @INC);
$ENV{'PATH'} = "$ENV{'PATH'};$inc";
$regexp = shift || die "usage: $0 regexp\n";
for $dir (split(/;/,$ENV{'PATH'}))
{
if ($dir =~ /^.*[\\\/]$/)
{
chop($dir);
}
if ($dir =~ /\//)
{
$delim = "\/";
}
else
{
$delim = "\\";
}
opendir(DOT, "$dir") || &cantdo($!);
while ($_ = readdir(DOT))
{
print "${dir}${delim}$_\n" if ($_ =~ /$regexp/i);
}
close(DOT);
}
sub cantdo
{
my $error = shift;
warn "can't opendir : $error\n";
next;
}
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
