PetaMem has asked for the wisdom of the Perl Monks concerning the following question:
Now this works great for me and some more rules and weīre at ~100%. The biggest culprit is, that it works for me only... As written in the sourcecode, the longest suffixes MUST be the last ones, as the longest suffixes MUST be examined as the first ones at runtime.#!/usr/bin/perl -w use strict; my $name = shift; &cz_vocativ_mask($name); sub cz_vocativ_mask { my $name = shift; # Important! The longest suffixes must be the last ones in this list. my %sufdata = ( a => 'o', s => 'si', k => 'ku', ar => 'ari', ic => 'ici', ec => 'ce', ek => 'ku', er => 'ere', # vec => 'evce', vec => 'veci', # Michal Svec is saying he likes this better ); foreach my $suffix (keys %sufdata) { if($name =~ /^(.*)$suffix$/) { print "Suffix $suffix -> $1$sufdata{$suffix}\n"; return; } } print " no rule apply -> $name\n"; }
The problem is, that the above piece of code indeed does examine the longest pieces first, but the people who applied this code in the DB-system say, the order of examination is completedly random.
So the behaviour of keys seems different, but we canīt see any difference (same perl version, same OS) the only difference is, that the code is just part of other code (but as separate routine also) and runs on a machine with less memory where it doesnīt seem to work "right".
Any suggestions how to FORCE the examination of longest keys first?
Any help greatly appreciated
Ciao
|
|---|