in reply to Looking for a Better Way to Substitute Characters (accents to HTML)

I don't know if it will help, but I just saw this on comp.lang.perl.misc,concerning a similar problem.

#by Janek Schleicher #favor using a module: use Regexp::Subst::Parallel; my $replaces_str = subst($string, qr/A/ => 'Y', qr/B/ => 'Z' ); ###################################### #Discussion: #using a hash my %substitute = (A => 'Y', B => 'Z'); my $keys = join "|", keys %substitute; s/($keys)/$substitute{$1}/g; #Disadvantages are that it becomes slow, #when there a lot of different expressions, #and it can lead to problems if there are some regexp characters insid +e. ############################################### #It's often extremely useful, #if you know that the matches can be matched with a more general one, #e.g. they are words: s/(\w+)/$substitute{$1} || ""/ge;
  • Comment on Re: Looking for a Better Way to Substitute Characters (accents to HTML)
  • Download Code