summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-07-31 17:49:30 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-07-31 17:49:30 +0000
commit416760cf6e1a2bcd8080388e290fa12e3e74c377 (patch)
tree2b841530dcd292a2559218349f0881c60d410999 /perl-install/common.pm
parent91419eac51774d733b905ac2d54b3bde60a208df (diff)
downloaddrakx-416760cf6e1a2bcd8080388e290fa12e3e74c377.tar
drakx-416760cf6e1a2bcd8080388e290fa12e3e74c377.tar.gz
drakx-416760cf6e1a2bcd8080388e290fa12e3e74c377.tar.bz2
drakx-416760cf6e1a2bcd8080388e290fa12e3e74c377.tar.xz
drakx-416760cf6e1a2bcd8080388e290fa12e3e74c377.zip
no_comment
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm25
1 files changed, 23 insertions, 2 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index c6d96682c..2fee51d59 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -6,9 +6,9 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
@ISA = qw(Exporter);
%EXPORT_TAGS = (
- common => [ qw(_ __ min max sum bool ikeys member divide is_empty_array_ref add2hash set_new set_add round_up round_down first second top uniq translate untranslate) ],
+ common => [ qw(_ __ min max sum product bool ikeys member divide is_empty_array_ref add2hash set_new set_add round_up round_down first second top uniq translate untranslate) ],
functional => [ qw(fold_left) ],
- file => [ qw(dirname basename touch all glob_ cat_ chop_ mode) ],
+ file => [ qw(dirname basename touch all glob_ cat_ chop_ mode getVarsFromSh) ],
system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ crypt_) ],
constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
);
@@ -26,6 +26,7 @@ sub __ { $_[0] }
sub min { fold_left(sub { $a < $b ? $a : $b }, @_) }
sub max { fold_left(sub { $a > $b ? $a : $b }, @_) }
sub sum { fold_left(sub { $a + $b }, @_) }
+sub product { fold_left(sub { $a * $b }, @_) }
sub first { $_[0] }
sub second { $_[1] }
sub top { $_[$#_] }
@@ -124,3 +125,23 @@ sub untranslate($@) {
foreach (@_) { translate($_) eq $s and return $_ }
die "untranslate failed";
}
+
+sub getVarsFromSh($) {
+ my %l;
+ local *F;
+ open F, $_[0] or return;
+ foreach (<F>) {
+ my ($v, $val, $val2) =
+ /^\s* # leading space
+ (\w+) = # variable
+ (
+ "([^"]*)" # double-quoted text "
+ | '([^']*)' # single-quoted text '
+ | [^'"\s]+ # normal text '
+ )
+ \s*$ # end of line
+ /x or next;
+ $l{$v} = $val2 || $val;
+ }
+ %l;
+}