develooper Front page | perl.perl6.language | Postings from September 2008

Re: Split with negative limits, and other weirdnesses

jason switzer
September 27, 2008 09:56
Re: Split with negative limits, and other weirdnesses
Message ID:
It makes sense to me to go with option 1; you get what you ask for. It also
makes sense to make to not use magical implied numbers, such as negatives,
to accomplish things that either ranges or whatever star can accomplish.

Just my 2 cents.

-Jason "s1n" Switzer

On Tue, Sep 23, 2008 at 4:27 AM, Moritz Lenz <>wrote:

> Today a patch to rakudo brought up the question what split() should do
> if the $limit argument is either zero or negative.
> In Perl 5 a negative limit means "unlimited", which we don't have to do
> because we have the Whatever star. A limit of 0 is basically ignored.
> Here are a few solution I could think of
>  1) A limit of 0 returns the empty list (you want zero items, you get them)
>  2) A limit of 0 fail()s
>  3) non-positive $limit arguments are rejected by the signature (Int
> where { $_ > 0 })
> Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About