Robert Brown wrote: > > Rob Dixon writes: > > > Tom Kinzer wrote: > > > I didn't think it was slick at all. In fact I was disappointed that > > it looked such a mess, but I don't see a better way. > > Yes, it is indeed a mess, not only syntacticly, but also semantically. > While it might make a good teaching example to show what you can do in > a perl regex, it might not be a very good way to do what is ultimately > accomplished. > > First, a regular expression pattern match is conducted to find all > chars in the string that are in the desired "special processing" > range. Note that these are each individual characters, not > substrings, so the regex match is gross overkill from a computational > complexity point of view. > > Second, all that is desired is to insert a circumflex and then the > character plus a bias to make it printable. > > Now if this is all that has to be done, and you want to do it to a > bunch of large files, then the way you show is a poor way to do it. A > simple C program could be written to get a character from stdin, check > it in an "if" statement to see if it is in the desired range, and then > output the circumflex followied by the biased character to stdout if > it is in the range, or else just output the character. This simple > one-char-at-a-time streaming filter approach would be considerably > simpler computationally than the method you provide. > > Now if you only need to do this to massage a few lines of output in a > program with a much larger overall purpose, then perhaps your example > is the way to go. > > My question is, how does perl's regex compiler handle the code you > gave? Does it optimize it to a similar level of complexity as my C > example, or does it smash it with a one-size-fits-all regular > expression engine? I know regular expressions can be highly optimized > at compile time, so this is an important question. If the regex is > sufficiently optimized, then it would always be the way to go.
Thanks Robert, but I wonder if you expect us to take you seriously? In which case I'll happily reply. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>