my ($cp) = grep { -x $_ } map { "$_/cp" } grep { length $_ } split /:/, $ENV{PATH}; die "cant find cp" unless defined $cp; my $output = `$cp source dest`;