On 8/9/05, Ronald J Kimball <[EMAIL PROTECTED]> wrote: > On Tue, Aug 09, 2005 at 09:07:16PM -0700, Stephen A. Jarjoura wrote: [...] > > Did I miss some obvious, and easier method? > > > > Basically, you need a loop. s///g allows you to hide the loop, but is less > efficient because you're updating the string. You could use m//g with an > explicit loop instead: > > $transfer_count++ while $buffer =~ m/\<transfer/g;
Beware when generalizing the above. How many copies of "hihi" are in "hihihihi"? How many copies of ".*" in ".*.*.*"? The latter can be fixed with the proper escapes. The former can be fixed either by using index() to do your searching, or by using pos() in the loop to set the match to just after the start of the match that you last found. (Unless overlapping matches are not allowed for your problem.) Cheers, Ben _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

