спасибо за отклик, но этот пример работает :
вот более полный фрагмент
my $t1 = new Benchmark;
my $ngram;
($_,$ngram) = @_; #$ngram contains reference to the hash we build
# then add the ngrams found in each word in the hash
my $word;
foreach $word (split("[$non_word_characters]+")) {
$word = "_" . $word . "_";
print "\\ntest=".$word;
my $len = length($word);
my $flen=$len;
my $i;
for ($i=0;$i<$flen;$i++) {
$$ngram {substr($word,$i,5)}++ if $len > 4;
$$ngram{substr($word,$i,4)}++ if $len > 3;
$$ngram{substr($word,$i,3)}++ if $len > 2;
$$ngram{substr($word,$i,2)}++ if $len > 1;
$$ngram{substr($word,$i,1)}++;
$len--;
}
}