in reply to Re^2: Calculations in Regexp
in thread Calculations in Regexp

If that is what you call “efficiency,” you are barking up the wrong tree for the wrong reasons.   No matter how “large” your text file may be, the CPU will spend the vast majority of its wall-time waiting for I/O.   It will spend an insignificant amount of time incrementing a variable, or even schlepping text around in memory (as long as virtual-storage paging is not “sneaking-in a significant amount of hidden I/O”).

What is a valid engineering concern, however, is just how easy it will continue to be to understand and to maintain your code in the future ... long after you have been smooshed (oops... hate it when that happens) by that most unfortunate bread truck.   Will your “clever trick” seem quite so clever when it turns into a bug?   Food for thought, and offered in that constructive spirit.