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

Re: Request review for adding a text trim() function to core

Thread Previous | Thread Next
Alexander Hartmaier
July 21, 2020 19:47
Re: Request review for adding a text trim() function to core
Message ID:
On Tue, Jul 21, 2020 at 8:35 PM Eric Brine <> wrote:

> Having a function to trim both ends but not one to trim trailing
> whitespace is really weird to me. Virtually every program I write needs the
> latter (though I usually settle for chomp).
> On Tue, Jul 21, 2020 at 1:59 PM Scott Baker <> wrote:
>> It's been a personal pet peeve of mine that Perl has never had a *trim()*
>> function in core. After discussion
>> <> with Grinnz, Leonerd, and
>> others we decided to move forward with seeing what it would take to add it
>> to core. I wrote documentation and tests, and LeoNerd wrote the actual
>> implementation. Now I'm here soliciting feedback on this feature before I
>> submit a formal PR.
>> You can checkout my branch here:
>> Once it's built the easier way to test it is: ./perl -Ilib -E 'say
>> CORE::trim("   Hello world!    ");'
>> You will get an experimental warning, but the function should work and
>> remove the whitespace.
>> - Scottchiefbaker
I've added some comments on Github but overall I'd love to see such a
Control over what characters should be trimmed would be awesome and default
to what it currently does.
That way you could also use it to trim brackets for example.

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