in reply to Re: Why study a SCALAR?
in thread Why study SCALAR?
One area where I'm currently using regexes is a 'simulator' that I've written in Perl, which basically interprets another language (a process control language). The syntax is different, this other language allows for arbitrarily complex expressions (really hairy 2-page messes with plenty of parentheses nesting, etc... nothing I'd want to maintain, and I'm glad I don't have to), and it also provides for an IF statement which tests whether an expression's value has gone from 0 to 1 (an edge-triggered device, to a hardware person). So it's not a trivial one-for-one translation. Bear in mind that I'm using some of the regexes to *alter* the original line; in essence, I translate it into the Perl equivalent and then use eval() to 'execute' it. Is this a candidate for the use of study($line), given that the $line is changing along the way? (If so, I will attempt to see if there's a speedup; right now, it's executing tens of thousands of lines in a little over a minute and I've got timestamping which could tell if there's anything to be gained.)