Skip to content

Instantly share code, notes, and snippets.

@gljeremy
Created September 22, 2011 17:56
Show Gist options
  • Save gljeremy/1235482 to your computer and use it in GitHub Desktop.
Save gljeremy/1235482 to your computer and use it in GitHub Desktop.
which command for windows
#! /usr/bin/perl
foreach my $arg (@ARGV) {
#print $arg, "\n";
my $found = 0;
foreach my $dir (split(/\;/, $ENV{"PATH"})) {
foreach my $ext ('', split(/\;/, $ENV{"PATHEXT"})) {
$fqpath = $dir . "\\" . $arg . $ext;
#print $fqpath, "\n";
if (-f $fqpath) {
print $fqpath, "\n";
$found++;
last;
}
}
last if $found;
}
if (! $found) {
print $arg " not found in ", $ENV{"PATH"}, "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment