Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!ncar!gatech!mcnc!uvaarpa!mmdf From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.perl Subject: need help with {n} and bracketing Message-ID: <1991Apr5.194317.10737@uvaarpa.Virginia.EDU> Date: 5 Apr 91 19:43:17 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.com Organization: The Internet Lines: 24 From: abe@mace.cc.purdue.edu (Vic Abell) Can anyone help me understand why the "((\w+\s+){3})" matching and bracketing expression didn't create four special Perl variables? For better or worse, because there are only two sets of parentheses (lexically speaking), there will only be $1 and $2. Every time the regexp inside a pair of parentheses matches, its match is loaded into the appropriate variable. Thus, only the last thing to match a pair of parentheses is available. For example: (regexp)* # $1 will be the last match of regexp Undoing assignments to variables while backtracking is done is a bear, but I assume that Perl does that correctly. Dale Dale Worley Compass, Inc. worley@compass.com -- We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris. -- Larry Wall and Randall Schwartz in "Programming Perl"