Shawn wrote: > > > If speed is important, it's good to avoid capturing. > > so $string =~ s/(\w+)_(?:NN|IN|AT)/$1/g; is quicker. > > Is there a big time savings since there is a capture anyway? > It can't be said in generally. It depends on the input and the perl version. But at least, it's always a little bit quicker.
In my experience, I often measured 1% till 5%. That's not much, but if there are some other chances to speed up, it can sum up to 30% or so. There's one exception of the rule: (\w+) or (\s+) is not slower than (?:\w+) or (\s+). Reason is, that Perl is trained for such typical capturing. I normally try to decide, whether speed is important or not. If so, I optimize speed like above, else I optimize readability with simple capturing. Rnoory didn't say something to this topic, but I assume, that he or she has to transform a big data file. Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]