$expression=shift;

if(`which $expression`){
  print `which $expression`;
}else{
  my @list=split " ",`locate $expression`;
  my (@result)=();
  for $i (@list){ 
    if($i=~m/$expression$/ && -x $i && -f $i){
      push @result,$i; 
      last
    }
  };
  print $result[0]
}
