Before I finally burst my cyanide capsule, may I.. ? Rj wrote: > > Rob Dixon writes: > > > > 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.
What is a syntactic mess? And, even more obscurely, what is a semantic mess? > 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. The stark realisation is that an infinite majority of problems have no solution at all. This is a Perl newsgroup. > 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. I've never before seen a software solution reverse-engineered as far as the documentation plus obfuscations! As far as possible a piece of software should be a description of what is to be done: that is what compilers/interpreters/assemblers/shell languages are for. Ideally what I should be able to write is: replace all control characters with their printable equivalents It is only the rigour of programming languages that prevents this. And why most companies still employ people. > 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. Now "Yes, it is indeed a mess, not only syntacticly, but also semantically." and "the way you show is a poor way to do it" is downright rude. Especially without an alternative option. Do you want to be taken seriously or what? I wrote an algorithm. If you have a problem with how well (in whatever sense) a computer executes that algorithm then you have an issue with the originators of the language and its implementors. I for one think that Perl is one of the best- conceived languages and certainly the best choice for any stand- alone program. > 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. How are you so sure that that's not how my algorithm is implemented by the compiler? > 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. Or perhaps it's the best way to go anyway? > 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. 'Sufficiently'? Why do you need to know? I know very well that I can write something in Intel assembler that will perform far faster than your C program. But I don't need to. I still don't understand your point. Just how fast do you need this thing to go? Why not just put stripes on it? Rob BTW have you read the context of your sig? Rj wrote: > > -------- "And there came a writing to him from Elijah" [2Ch 21:12] -------- > R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 847 543-4060 > Elijah Laboratories Inc. 457 Signal Lane, Grayslake IL 60030 fax 847 543-4061 > ----- M o d e l i n g t h e M e t h o d s o f t h e M i n d ------ 2 Chronicles 21:12,13 Jehoram received a letter from Elijah the prophet, which said: "This is what the LORD, the God of your father David, says: 'You have not walked in the ways of your father Jehoshaphat or of Asa king of Judah. But you have walked in the ways of the kings of Israel, and you have led Judah and the people of Jerusalem to prostitute themselves, just as the house of Ahab did. You have also murdered your own brothers, members of your father's house, men who were better than you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>