(Keeping in mind that I don’t speak perl.)
Ya know, @lucy24, I kinda get the feeling that I might be the last person in the world using Perl! LOL I noticed that, with 1 exception, I'm the only one that has started any threads in this subforum for almost 3 years!
Which blows my mind, really. Perl was the first language I learned, and it's WAY more powerful than any of the others I've used! I honestly think that if it weren't for the
cgi-bin requirement (so that the user could use /home/example/www/index.cgi) then it would still be the most popular.
But anyway.
“Looping through 300 Regular Expressions” sounds like the title of a work of art, but I can’t decide which art.
Kinda reminds me more of "Death by a Thousand Cuts" :-O LOL
I'm finding that I use this same type of loop repeatedly across scripts, and combined it's definitely a bottleneck. There HAS to be a better way! Just 15 minutes ago I found where I'd done this same thing several years ago:
%asciiChars = (
'592' =>'a',
'596' =>'c',
# 101 more of these
'347' =>'s'
);
if (/&#\d+;/) {
foreach $key (keys %asciiChars) {
s/&#$key;/$asciiChars{$key}/g;
}
}
At least in that one I could easily test for matches before getting in the loop, but if a submission included
ś then it still resulted in 104 expressions :-/
I was able to make it better using:
@matches = /&#(\d+);/g;
foreach $key (@matches) {
s/&#$key;/$asciiChars{$key}/g;
}
Now it only runs the expressions that have prematched; meaning, if a submission includes
ś then it just runs the 2 expressions (the one to set @match, and then the one in the loop).
The problem that prompted this thread doesn't have that option, but I MAY have found a workaround... I'll update the earlier thread:
[
webmasterworld.com...]