Not sure I'm getting it completely, but using match in a while loop w/ the /g modifier lets you process a string one match at a time: my $string = "Lots of words to be read one at a time.\nthough more than one line"; while ( $string =~ /(\w+)/g ) { print "Found: $1\n"; print "Proceessing ...\n"; } # while /(\w+)/g
While the original string should be left alone (so pos and \G (the marker for the last match) don't get confused) you can process/chop up a copy of the string as you go. To get really tricky, you can munge the string and matches via assignments to pos() - best to look at "Mastering Regular Expressions" (O'Reilly/Freidl - or better, buy it!) Chapter 7ish. That's not for the fainthearted. @nums = $data =~ m/\d+/g; # pick apart string, returning a list of numbers Suppose the list of numbers starts *after* a marker - "<xx>" - prime the 'pos' $data =~ m/<xx>/g; # prime the /g start, pos($data) now point to just after the "<xx>" @nums = $data =~ m/\d+/g; # pick apart the rest of the string, returning a list of numbers Or: pos($data) = $i if $i = index($data, "<xx>"), $i > 0; # find the "<xx>" @nums = $data =~ m/\d+/g; # pick apart the rest of the string, returning a list of numbers difference here is pos is just before the "<xx>" while in the previous, its just after but ... a Andy Bach, Sys. Mangler Internet: [EMAIL PROTECTED] VOICE: (608) 261-5738 FAX 264-5932 " History will have to record that the greatest tragedy of this period of social transition was not the strident clamor of the bad people, but the appalling silence of the good people. " Martin Luther King, Jr. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs