in reply to using tr///
Have you considered HTML::Entities?my %subst = ( '&' => 'amp', '>' => 'gt', '<' => 'lt' ); my $alternatives = join('|', map quotemeta, sort { length($b) <=> leng +th($a) || $b cmp $a } keys %subst); $string =~ s/($alternatives)/$subst{$1}/ge;
Hmm. I suppose if your input string were just ASCII, you could do tr///'s to carefully selected unicode characters, then turn off the utf8 flag and do a second tr to produce the desired letters. But that would be sick and twisted.
|
|---|