use File::Spec; my @exec = map { my $p = $_; grep { -f and -x } map File::Spec->catfile($p, "$f$_"), '', qw(.exe .com .bat) } File::Spec->path or die "Can't find executable $f"; #### #!/usr/bin/perl -wl use File::Which; open OUT, '>complexe'; close OUT; print for which('complexe'); #### .\complexe