summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorpad <pad@mandriva.com>1999-09-14 14:50:50 +0000
committerpad <pad@mandriva.com>1999-09-14 14:50:50 +0000
commit0aa7a9e98c3b51085c87aa13d61eef8e3f694626 (patch)
tree06c3462cb7af3adb37d3a4606dd43d2604b88eec /perl-install/common.pm
parent951e65ef820631665dbeddf6cfb43afce034efb9 (diff)
downloaddrakx-backup-do-not-use-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar
drakx-backup-do-not-use-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.gz
drakx-backup-do-not-use-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.bz2
drakx-backup-do-not-use-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.xz
drakx-backup-do-not-use-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.zip
*** empty log message ***
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm47
1 files changed, 46 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 5fa40e2b1..d30906a21 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -14,12 +14,18 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
+
+#-#####################################################################################
+#- Globals
+#-#####################################################################################
$printable_chars = "\x20-\x7E";
$sizeof_int = psizeof("i");
$bitof_int = $sizeof_int * 8;
$SECTORSIZE = 512;
-1;
+#-#####################################################################################
+#- Functions
+#-#####################################################################################
sub fold_left(&@) {
my $f = shift;
@@ -264,7 +270,24 @@ sub setVarsInSh {
$l->{$_} and print F "$_=$l->{$_}\n" foreach @fields;
}
+
+sub best_match {
+ my ($str, @lis) = @_;
+ my @words = split /\W+/, $str;
+ my ($max, $res) = 0;
+
+ foreach (@lis) {
+ my $count = 0;
+ foreach my $i (@words) {
+ $count++ if /$i/i;
+ }
+ $max = $count, $res = $_ if $count >= $max;
+ }
+ $res;
+}
+
sub bestMatchSentence {
+
my $best = -1;
my $bestSentence;
my @s = split /\W+/, shift;
@@ -277,3 +300,25 @@ sub bestMatchSentence {
}
$bestSentence;
}
+
+# count the number of character that match
+sub bestMatchSentence2 {
+
+ my $best = -1;
+ my $bestSentence;
+ my @s = split /\W+/, shift;
+ foreach (@_) {
+ my $count = 0;
+ foreach my $e (@s) {
+ $count+= length ($e) if /$e/i;
+ }
+ $best = $count, $bestSentence = $_ if $count > $best;
+ }
+ $bestSentence;
+}
+
+
+#-######################################################################################
+#- Wonderful perl :(
+#-######################################################################################
+1; #