develooper Front page | perl.perl5.porters | Postings from November 2020

Re: Looking for someone to adopt adding trim() to core

Thread Previous | Thread Next
Vlado Keselj
November 26, 2020 12:53
Re: Looking for someone to adopt adding trim() to core
Message ID:

1050 distributions and 1659 cases!  Wow, that is a strong support for 

It is interesting that some of those cases use /g option, which trims all 
lines.  This could be a candidate for the second argument of "trim".

I would guess that not even all alternatives are counted, like:

On Thu, 26 Nov 2020, Christian Walde wrote:

> On Thu, 26 Nov 2020 12:43:01 +0100, Vlado Keselj <> wrote:
> >Hi,
> >
> >I am new to the list so I am not sure if this counts for much, but I would
> >be in support of making "trim" a keyword.
> >
> >Perl is a string-oriented language and it should be simple and transparent
> >to use functions like "trim", which made keywords already in other
> >languages, like PHP.  Yes, we can use regexes but they do look hairy for
> >such a simple use.  This would be an important benefit to the beginners.
> >If 'chomp' is there, why 'trim' would not be.  One possible dowside may be
> >backcompatibility.  It would be worth checking how much and how 'trim' has
> >already been used in CPAN.
> Thanks for the support. :)
> As for the numbers checking, i already did that here:
> >And looking at CPAN:
> >
> >1050 distributions and 1659 files implement some kind of regex-based
> >whitespace stripping, and while this function isn't aimed at CPAN, this
> >demonstrates a clear desire.
> >For a (not at all equal, but related) comparison, searching for uses of say:
> >
> >results in 914 dists.
> That said, backporting is not a big concern for this one, as trim is primarily
> aimed at non-CPAN developers for their own code, as trim is more likely to be
> used in end user code, not library code. :)
> It would also be a small marketing win alongside of the other benefits of it
> being a proof-of-concept and learning aid for adding functionality to Perl.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About