summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-01-07 16:30:02 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-01-07 16:30:02 +0000
commit57035179187542b3c57ce162d61d72bccb552bb4 (patch)
tree659ed8bde7432f097738d3fd9b1867e8a3019ed5 /MDK
parentb04a6e35dc512445ef37c6286845ec79e6aa83dc (diff)
downloadperl-MDK-Common-57035179187542b3c57ce162d61d72bccb552bb4.tar
perl-MDK-Common-57035179187542b3c57ce162d61d72bccb552bb4.tar.gz
perl-MDK-Common-57035179187542b3c57ce162d61d72bccb552bb4.tar.bz2
perl-MDK-Common-57035179187542b3c57ce162d61d72bccb552bb4.tar.xz
perl-MDK-Common-57035179187542b3c57ce162d61d72bccb552bb4.zip
add whereis_binary()
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common.pm.pl2
-rw-r--r--MDK/Common/System.pm14
2 files changed, 13 insertions, 3 deletions
diff --git a/MDK/Common.pm.pl b/MDK/Common.pm.pl
index 914d59c..e042014 100644
--- a/MDK/Common.pm.pl
+++ b/MDK/Common.pm.pl
@@ -71,7 +71,7 @@ use vars qw(@ISA @EXPORT $VERSION); #);
# perl_checker: RE-EXPORT-ALL
@EXPORT = map { @$_ } map { values %{'MDK::Common::' . $_ . 'EXPORT_TAGS'} } grep { /::$/ } keys %MDK::Common::;
-$VERSION = "1.1.9";
+$VERSION = "1.1.10";
1;
EOF
diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm
index 40c1fc8..5ecdc86 100644
--- a/MDK/Common/System.pm
+++ b/MDK/Common/System.pm
@@ -88,6 +88,10 @@ returns the epoch in microseconds
takes care of CR/LF translation
+=item whereis_binary(STRING)
+
+return the first absolute file in $PATH (similar to which(1) and whereis(1))
+
=item getVarsFromSh(FILENAME)
returns a hash associating shell variables to their value. useful for config
@@ -175,7 +179,7 @@ use MDK::Common::File;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK %compat_arch $printable_chars $sizeof_int $bitof_int); #);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch typeFromMagic list_passwd list_home list_skels list_users syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos getVarsFromSh setVarsInSh setVarsInShMode setExportedVarsInSh setExportedVarsInCsh template2file template2userfile read_gnomekderc update_gnomekderc fuzzy_pidofs); #);
+@EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch typeFromMagic list_passwd list_home list_skels list_users syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos whereis_binary getVarsFromSh setVarsInSh setVarsInShMode setExportedVarsInSh setExportedVarsInCsh template2file template2userfile read_gnomekderc update_gnomekderc fuzzy_pidofs); #);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@@ -285,7 +289,13 @@ sub availableRamMB() { 4 * MDK::Common::Math::round((-s '/proc/kcore') / 1024 /
sub gettimeofday() { my $t = pack "LL"; syscall_('gettimeofday', $t, 0) or die "gettimeofday failed: $!\n"; unpack("LL", $t) }
sub unix2dos { local $_ = $_[0]; s/\015$//mg; s/$/\015/mg; $_ }
-
+sub whereis_binary {
+ my ($prog) = @_;
+ foreach (split(':', $ENV{PATH})) {
+ my $f = "$_/$prog";
+ -x $f and return $f;
+ }
+}
sub getVarsFromSh {
my %l;