my $tool_name = "tar"; # simple example my $tool_path = ''; for my $path ( split /:/, $ENV{PATH} ) { if ( -f "$path/$tool_name" && -x _ ) { print "$tool_name found in $path\n"; $tool_path = "$path/$tool_name"; last; } } die "No $tool_name command available\n" unless ( $tool_path ); #### my $tool_name = "tar"; my $tool_path = `which $tool_name`; die "No $tool_name command available\n" unless ( $tool_path );