use File::Find::Rule; sub in_path { my ($cmd, $path) = @_; my @files = File::Find::Rule->file()->name($cmd)->maxdepth(1)->in( split /:/, $path ) or return 'not found'; return grep(-x $_,@files) ? 'exe' : 'plain'; } #### return File::Find::Rule->file()->executable->name($cmd)->maxdepth(1)->in( split /:/, $path ) ? 1 : undef;