summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorpad <pad@mandriva.com>1999-09-03 13:44:30 +0000
committerpad <pad@mandriva.com>1999-09-03 13:44:30 +0000
commit59a71876a17e616e3706c80cddf3e74f34bbcf67 (patch)
treee52f9979a37b9e3256a5f764d8c9f4cc85b9464f /perl-install/common.pm
parent874f08a1316d73d6f09f0ca2df235dac495a387b (diff)
downloaddrakx-backup-do-not-use-59a71876a17e616e3706c80cddf3e74f34bbcf67.tar
drakx-backup-do-not-use-59a71876a17e616e3706c80cddf3e74f34bbcf67.tar.gz
drakx-backup-do-not-use-59a71876a17e616e3706c80cddf3e74f34bbcf67.tar.bz2
drakx-backup-do-not-use-59a71876a17e616e3706c80cddf3e74f34bbcf67.tar.xz
drakx-backup-do-not-use-59a71876a17e616e3706c80cddf3e74f34bbcf67.zip
pad stuff
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm34
1 files changed, 25 insertions, 9 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 329dceaae..05091d546 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -6,18 +6,18 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
@ISA = qw(Exporter);
%EXPORT_TAGS = (
- common => [ qw(__ min max sum sign product bool bool2text ikeys member divide is_empty_array_ref add2hash set_new set_add round_up round_down first second top uniq translate untranslate warp_text) ],
- functional => [ qw(fold_left map_index mapn mapn_ difference2 before_leaving catch_cdie cdie) ],
- file => [ qw(dirname basename touch all glob_ cat_ chop_ mode) ],
- system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ crypt_ getVarsFromSh setVarsInSh) ],
- constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
+ common => [ qw(__ min max sum sign product bool bool2text ikeys member divide is_empty_array_ref add2hash set_new set_add round_up round_down first second top uniq translate untranslate warp_text) ],
+ functional => [ qw(fold_left map_index map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ],
+ file => [ qw(dirname basename touch all glob_ cat_ chop_ mode) ],
+ system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ crypt_ getVarsFromSh setVarsInSh) ],
+ constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
-$printable_chars = "\x20-\x7E";
-$sizeof_int = psizeof("i");
-$bitof_int = $sizeof_int * 8;
-$SECTORSIZE = 512;
+$printable_chars = "\x20-\x7E";
+$sizeof_int = psizeof("i");
+$bitof_int = $sizeof_int * 8;
+$SECTORSIZE = 512;
1;
@@ -84,6 +84,20 @@ sub map_index(&@) {
@l;
}
+#pseudo-array-hash :)
+sub map_tab_hash(&$@) {
+ my ($f, $fields, @tab_hash) = @_;
+ my %hash;
+ my $key = { map_index {($_, $::i + 1)} @{$fields} };
+
+ for (my $i = 0; $i < @tab_hash; $i += 2) {
+ my $h = [$key, @{$tab_hash[$i + 1]}];
+ &$f($i, $h) if $f;
+ $hash{ $tab_hash[$i] } = $h;
+ }
+ %hash;
+}
+
sub smapn {
my $f = shift;
my $n = shift;
@@ -247,3 +261,5 @@ sub setVarsInSh {
open F, "> $_[0]" or die "cannot create config file $file";
$l->{$_} and print F "$_=$l->{$_}\n" foreach @fields;
}
+
+