diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-09-07 18:56:58 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-09-07 18:56:58 +0000 |
commit | b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac (patch) | |
tree | 41dee19ea5321514d7b99e472ba6706f2cca484a /perl-install/common.pm | |
parent | 0a0d5a1f290319b767e7078c8173f013a5bb842f (diff) | |
download | drakx-b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac.tar drakx-b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac.tar.gz drakx-b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac.tar.bz2 drakx-b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac.tar.xz drakx-b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac.zip |
no_comment
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r-- | perl-install/common.pm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 05091d546..084080959 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -55,6 +55,7 @@ sub round_up { my ($i, $r) = @_; $i += $r - ($i + $r - 1) % $r - 1; } sub round_down { my ($i, $r) = @_; $i -= $i % $r; } sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 } sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} } +sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = (); } keys %l } sub set_new(@) { my %l; @l{@_} = undef; { list => [ @_ ], hash => \%l } } sub set_add($@) { my $o = shift; foreach (@_) { exists $o->{hash}{$_} and next; push @{$o->{list}}, $_; $o->{hash}{$_} = undef } } @@ -242,9 +243,9 @@ sub getVarsFromSh($) { /^\s* # leading space (\w+) = # variable ( - "([^"]*)" # double-quoted text " - | '([^']*)' # single-quoted text ' - | [^'"\s]+ # normal text ' + "([^"]*)" # double-quoted text + | '([^']*)' # single-quoted text + | [^'"\s]+ # normal text ) \s*$ # end of line /x or next; @@ -262,4 +263,16 @@ sub setVarsInSh { $l->{$_} and print F "$_=$l->{$_}\n" foreach @fields; } - +sub bestMatchSentence { + my $best = -1; + my $bestSentence; + my @s = split /\W+/, shift; + foreach (@_) { + my $count = 0; + foreach my $e (@s) { + $count++ if /$e/i; + } + $best = $count, $bestSentence = $_ if $count > $best; + } + $bestSentence; +} |