summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;