Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!bcm!convex!newsadm From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: need help with {n} and bracketing Message-ID: <1991Apr05.191840.19993@convex.com> Date: 5 Apr 91 19:18:40 GMT References: <7171@mace.cc.purdue.edu> Sender: newsadm@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 23 Nntp-Posting-Host: pixel.convex.com From the keyboard of abe@mace.cc.purdue.edu (Vic Abell): :The following Perl program: : : if ("one two three four\n" =~ /^((\w+\s+){3})/) { : print '"', $1, "\" \"", $2, "\" \"", $3, "\" \"", $4, "\"\n"; : } else { : print "No match!\n"; : } : :produces: : : "one two three " "three " "" "" : :I expected: : : "one two three " "one " "two " "three " : :Can anyone help me understand why the "((\w+\s+){3})" matching and :bracketing expression didn't create four special Perl variables? There are only two (paren-pairs), so you only get two variables. --tom