From b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 7 Sep 1999 16:04:35 +0000 Subject: no_comment --- perl-install/modparm.pm | 65 +++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 45 deletions(-) (limited to 'perl-install/modparm.pm') diff --git a/perl-install/modparm.pm b/perl-install/modparm.pm index a630cdd5c..cfbd063b5 100644 --- a/perl-install/modparm.pm +++ b/perl-install/modparm.pm @@ -1,14 +1,20 @@ package modparm; +use diagnostics; +use strict; + +use common qw(:common); use log; + my %modparm_hash; sub read_modparm_file($) { my ($file) = @_; my @line; - open F, $file; + local *F; + open F, $file or log::l("missing $file: $!"), return; while () { chomp; @line = split ':'; @@ -19,60 +25,29 @@ sub read_modparm_file($) { desc => $line [4], }; } - close F; } -sub get_options_result($;$) { - my ($module,$value) = @_; - my @names = keys %{$modparm_hash{$module}}; - my $options; - my $result; - my $i; +sub get_options_result($@) { + my ($module, @value) = @_; - for $i (0..$#$value) { - $result = $ {$value->[$i]}; - - if ($result != "") { - $options .= "$names[$i]=$result "; - } - } - - return $options; + mapn { + my ($a, $b) = @_; + $a ? "$b=$a" : () + } \@value, [ keys %{$modparm_hash{$module}} ]; } sub get_options_name($) { my ($module) = @_; - my @names = keys %{$modparm_hash{$module}}; - my @result; - my $opttype; - my $default; + my @names; - foreach (@names) { - $opttype = $modparm_hash{$module}{$_}{type}; - $default = $modparm_hash{$module}{$_}{default}; + %modparm_hash or return; - if (defined($default)) { - push @result, _("$_ ($opttype)[$default]"); - } else { - push @result, _("$_ ($opttype)"); - } + while (my ($k, $v) = each %{$modparm_hash{$module} || {}}) { + my $opttype = $v->{type}; + my $default = $v->{default}; + push @names, "$k ($v->{type})" . (defined($v->{default}) && "[$v->{default}]"); } - - return \@result; -} - -sub get_options_value($) { - my ($module) = @_; - my @names = keys %{$modparm_hash{$module}}; - my @result; - - for $i (0..$#names) { - my $value = ""; - - $result[$i] = \$value; - } - - return \@result; + @names; } read_modparm_file("/tmp/modparm.txt"); -- cgit v1.2.1