go ahead... be a heretic | |
PerlMonks |
Looking for a Better Way to Substitute Characters (accents to HTML)by svsingh (Priest) |
on May 10, 2003 at 14:53 UTC ( [id://257127]=perlquestion: print w/replies, xml ) | Need Help?? |
svsingh has asked for the wisdom of the Perl Monks concerning the following question:
Now that I'm more comfortable with Perl, I'm going through some of my old Pascal programs and trying to rewrite them in Perl. Partly to web-enable them, and partly for practice.
I'm working on one now that reads a text file and creates an HTML file. The text file contains some accented letters (i.e. é). My first instinct is to use a substitution to replace the accented characters with the proper HTML equivalents (i.e. é), but the text file is about 200 kb and there are eight accents that I know of. Running every character (by line) through that many substitutions seems to be a lot more overhead than I want for a dynamic page. I'm trying to find a method that can do this for me under the assumption that built-in methods are faster. It would also be nice to have a solution that doesn't require me adding another substitution everytime a new accent shows up in the text file. I tried Perl Monks, the Black Book, the Cookbook, and a few web sites. No luck yet. Am I missing something, or do I have to build this from scratch? If so, then is there a smarter way than individual substitutions? Thank you.
Back to
Seekers of Perl Wisdom
|
|