in reply to Re^2: Combining regexes
in thread Combining regexes

"single character substitutions are better done with tr///" is not something I have seen documented anywhere. Is this a question of experience, or something I should have found for myself?

Just adding on to BrowserUk's comments re: tr. Another big factor is that tr doesn't have to worry about the string getting longer! You can't substitute one character with 2 others. But that means that tr doesn't have any memory allocation worries (getting shorter is a whole different deal than getting longer). The net result of all of these simplifications means that tr runs like a rocket.

Update: This thread about tr got me thinking... I volunteer as a TA for a MASM (Microsoft Assembly) class at a local college. We are always thinking of new labs. A "tr" lab is likely to appear in the Fall 2016! The C version of tr is fast, the assembly language version will be really, really fast. And we can teach some other stuff along the way. Quoting my prof for the suggestion of a tr lab:

Implementing tr is a good exercise! It makes use of the optimized array instructions and it reinforces the idea that characters are just integers, which, as you recall from the last ASM class, some students had a hard time converting a digit to its ASCII character. Thanks!

Sometimes these Perl questions spawn other thoughts. Have no doubt that tr can be implemented very efficiently in ASM class 101. That is definitely not true of regex!