<a href="http://www.perl.com/lpt/a/2003/07/15/nocode.html">How to Avoid Writing Code</a>


How to Avoid Writing Code

21.12.2003, 22:46 · Martin · Permalink

Just right to lift my Perl-spirit once again here comes an articel (thx Keith) dealing with how the combination of Class::DBI and Template Toolkit can make you're coding work real fun and effective...

Below some quotes from that article I find extremly usefull, if actually unrelated to the Class::DBI thing per se:
We start with a very simple canonicalization--stripping out vowels and collapsing repeated letters. (I've found that this can pick up about half of name misspellings found in the wild, which is pretty impressive.)
sub _canonicalise {
      my ($class, $word) = @_;
      return "" unless $word;
      $word = lc($word);
      $word =~ s/[aeiou]//g;    
      # remove vowels
      $word =~ s/(\w)\1+/$1/eg; 
      # collapse doubled 
      # (or tripled, etc) letters
      return $word;
}

(The matching method can be improved. I've found that neither Text::Soundex nor Text::Metaphone are much of an improvement over the simple approach already detailed, but Text::DoubleMetaphone is definitely worth plugging in, to catch misspellings such as Nicolas/Nicholas and Asimov/Azimof.)

I guess Perl can actually be FUN at times ;) (as if I didn't know anyway)


alles Bild, Text und Tonmaterial ist © Martin Spernau, Verwendung und Reproduktion erfordert die Zustimmung des Authors

Martin Spernau
© 1994-2026


amazon.de Wunschliste

Facebook me!
Google+

powered by Traumtank