summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-01-31 23:15:34 +0000
committerfukachan <fukachan>2001-01-31 23:15:34 +0000
commit70c48b2a4854a5bdbb213964b861f32a9c3ffda4 (patch)
treea183a20be93083b04c458154bfc4c508936a0b7a /fml
parentc196fd1a741b3e379da6f43940291e716d92a347 (diff)
downloadfml8-70c48b2a4854a5bdbb213964b861f32a9c3ffda4.tar.gz
fml8-70c48b2a4854a5bdbb213964b861f32a9c3ffda4.tar.bz2
fml8-70c48b2a4854a5bdbb213964b861f32a9c3ffda4.zip
add search_program() which searches executable.
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Utils.pm30
1 files changed, 29 insertions, 1 deletions
diff --git a/fml/lib/FML/Utils.pm b/fml/lib/FML/Utils.pm
index e4b93a6c..801bd581 100644
--- a/fml/lib/FML/Utils.pm
+++ b/fml/lib/FML/Utils.pm
@@ -16,7 +16,7 @@ use Carp;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(mkdirhier touch);
+@EXPORT_OK = qw(mkdirhier touch search_program);
=head1 NAME
@@ -96,4 +96,32 @@ sub touch
}
+sub search_program
+{
+ my ($file, $path_list) = @_;
+
+ my $default_path_list = [
+ '/usr/bin',
+ '/bin',
+ '/sbin',
+ '/usr/local/bin',
+ '/usr/gnu/bin',
+ '/usr/pkg/bin'
+ ];
+
+ $path_list ||= $default_path_list;
+
+ use File::Spec;
+ my $path;
+ for $path (@$path_list) {
+ my $prog = File::Spec->catfile($path, $file);
+ if (-x $prog) {
+ return $prog;
+ }
+ }
+
+ return wantarray ? () : undef;
+}
+
+
1;