=head1 TITLE Allow multiply matched groups in regexes to return a listref of all matches =head1 VERSION Maintainer: Kevin Walker <[EMAIL PROTECTED]> Date: 30 Sep 2000 Version: 1 Mailing List: [EMAIL PROTECTED] Status: Frozen =head1 DESCRIPTION Since the October 1 RFC deadline is nigh, this will be pretty informal. Suppose you want to parse text with looks like: name: John Abajace children: Tom, Dick, Harry favorite colors: red, green, blue name: I. J. Reilly children: Jane, Gertrude favorite colors: black, white ... Currently, this takes two passes: while ($text =~ /name:\s*(.*?)\n\s* children:\s*(.*?)\n\s* favorite\ colors:\s*(.*?)\n/sigx) { # now second pass for $2 ( = "Tom, Dick, Harry") and $3, yielding # list of children and favorite colors } If we introduce a new construction, (?@ ... ), which means "spit out a list ref of all matches, not just the last match", then this could be done in one pass: while ($text =~ /name:\s*(.*?)\n\s* children:\s*(?:(?@\S+)[, ]*)*\n\s* favorite\ colors:\s*(?:(?@\S+)[, ]*)*\n/sigx) { # now we have: # $1 = "John Abajace"; # $2 = ["Tom", "Dick", "Harry"] # $3 = ["red", "green", "blue"] } Although the above example is contrived, I have very often felt the need for this feature in real-world projects. =head1 IMPLEMENTATION Unknown. =head1 REFERENCES None.