On Thu, Mar 26, 2009 at 06:00:29PM -0700, Ron Schmidt via RT wrote: > Please find attached a patch to implement requested functionality. > Passes split-simple.t tests and includes a patch that updates those > tests and adds one more that verifies correct performance with a return > limit count.
> Index: t/spec/S32-str/split-simple.t > =================================================================== > --- t/spec/S32-str/split-simple.t (revision 26002) > +++ t/spec/S32-str/split-simple.t (working copy) > @@ -2,7 +2,7 @@ > use Test; > > # L<S29/Str/"=item split"> > -plan 45; > +plan 46; > > =begin description > > @@ -83,12 +83,13 @@ > > # split should return capture > my @split = 'abc def ghi'.split(/(\s+)/); > -#?rakudo todo "split should return captures" > -#?DOES 3 > -{ > - ok @split.elems == 5, q{split returns captured delimiter} ; > - ok @split[1] eq ' ', q{split captured single space}; > - ok @split[3] eq ' ', q{split captured multiple spaces}; > -} > +ok @split.elems == 5, q{split returns captured delimiter} ; > +ok @split[1] eq ' ', q{split captured single space}; > +ok @split[3] eq ' ', q{split captured multiple spaces}; > +...@split = 'abc::def::ghi'.split(/(\:)/, 5); > +ok @split.elems == 5 and > + @split[3] eq 'def' and > + @split[4] eq ':', > + q{split with capture obeyed limit}; That's not right, is it? Or I don't understand what perl 6 does with the capturing parens that's different from perl 5. In perl 5 (and what I would expect from perl 6), @split would contain the following strings at the following array indices: 0 "abc" 1 ":" 2 "" 3 ":" 4 "def" 5 ":" 6 "" 7 ":" 8 "ghi" I assume the error is because of the switch in the string from using a single delimiter to using two delimiters (or from not using /'::'/ as the regex depending on how you look at things). Also, setting the limit parameter to 5 seems fairly useless in the example because there's only 5 things to split to begin with. Usually the limit comes in to play when your string contains more pieces that are potentially splittable on your delimiter than what you want. For instance, if the string were "abc::def::ghi::jkl", @split would contain ("abc",":","",":","def",":","",":","ghi::jkl") -Scott -- Jonathan Scott Duff d...@lighthouse.tamucc.edu