use File::Spec; sub find_in_path { my $prog = shift; my $fmm; for my $d (File::Spec->path()) { $fnm = File::Spec->catfile($d,$prog); last if -x fnm; $fnm = undef; } return $fnm; } my $excel = find_in_path('excel.exe');