TMTOWTDI - this is a more general solution that remaps characters in a string in a fairly (cough) efficient manner. You'd want to use this in conjunction with a Swartzian transform.
my @lowervec = (
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
' ','!','"','#','$','%','&','\'','','','*','+','','','','',
'0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?',
'@','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
'p','q','r','s','t','u','v','w','x','y','z','[','\\',']','^','_',
'`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~',127,
'c','u','e','a','a','a','a','c','e','e','e','i','i','i','a','a',
'e',145,'','o','o','o','u','u','y','o','u',155,156,157,158,159,
'a','i','o','u','n','n',166,167,168,169,170,'',172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,'',188,189,190,191,
192,193,194,195,196,197,198,199,200,'e',202,203,204,205,206,207,
208,209,210,211,212,213,'o',215,216,217,218,219,220,221,222,223,
'a','a',226,227,'a',229,230,'c',232,'e',234,'e',236,'i',238,239,
240,241,242,'o','o',245,'o',247,248,249,250,251,'u','y',254,255,
);
# Lowercases string, remaps accented chars and removes some non-alphab
+etic chars
sub cleanstring($) {
return join('', map { $lowervec[ord($_)] } split('', shift));
}
-- Michael Snell
-- michael@snell.com
|