Path: utzoo!utgpu!cunews2!cunews!micor!latour!ecicrl!eci386!jmm From: jmm@eci386.uucp (John Macdonald) Newsgroups: comp.lang.perl Subject: Re: Counting RE occurrences Keywords: regexps, /g, /n, split, arrays, APL, invert Message-ID: <1991May22.232735.22936@eci386.uucp> Date: 22 May 91 23:27:35 GMT References: <1991May13.225603.29819@convex.com> <1991May16.010149.20536@uunet.uu.net> <1991May17.132403.12104@convex.com> <1991May21.184545.26905@uunet.uu.net> Reply-To: jmm@eci386.UUCP (John Macdonald) Organization: Elegant Communications Inc. Lines: 31 In article <1991May21.184545.26905@uunet.uu.net> rbj@uunet.uu.net (Root Boy Jim) writes: |tchrist@convex.COM (Tom Christiansen) writes: |?I've also been thinking more about |? |? while (/foo/) { |? |?and somehow making that an iterator that starts the match from where it |?left off. I think a decent way to do this would be to use a /n flag |?indicating "next match". Thus the syntax would be //n, or m//n. | |I am leery of these operators with embedded state. It's just |another thing that has to be cleaned up. If this sort of thing is going to be added, then perhaps it would be appropriate to add iterators as a formal object within the language, merging the concepts of globbing, ARGV handle scanning using <>, numerical and string iterators ('aa'..'zz'), and the (as proposed) some sort of RE iterators. Iterators as a class could have the operations of rewind, check if done, start next iteration, terminate the iterator, and any others that seem appropriate. Most of these operations fit in well with embedding the iterator in a for or while loop and using the loop control statements (next, last, first[a new one to rewind the iterator back to its beginning]). Perl already has picked up concept from lots of other languages, maybe its time to get some from ICON. -- sendmail - as easy to operate and as painless as using | John Macdonald manually powered dental tools on yourself - John R. MacMillan | jmm@eci386